BatchSampler: Sampling Mini-Batches for Contrastive Learning in Vision, Language, and Graphs