Solved by ptrblck in post #2 
              
              
                That’s an interesting use case! 
Basically you could just use the subset indices to create your WeightedRandomSampler, i.e. calculate the class imbalance, weights etc. 
Here is a small example: 
# Create dummy data with class imbalance 99 to 1
numDataPoints = 1000
data_dim = 5
bs = 100
data = torch.…