Imbalanced dataset

I don’t know what’s causing the error, so would need to see the torchsampler implementation to figure our what might be causing it and how to fix it.
Generally, you could use the PyTorch WeightedRandomSampler as described e.g. here.