your understanding may be correct,pls reference here ,perhps it helps.

  
    
    
    Balanced Sampling between classes with torchvision DataLoader vision
  
  
    you should look at How to Prevent Overfitting