Heterogeneity-aware and communication-efficient distributed statistical inference