I have currently found the answer here:

  
    
    
    How to enable the dataloader to sample from each class with equal probability 
  
  
    The dataloader utility in torch (courtesy of Soumith Chintala) allowed one to sample from each class with equal probability. I was wondering, if there is a straightforward approach to enable the same in pytorch dataloaders.