Contrastive Learning with Complex Heterogeneity