How to sample different number of samples in each mini batch?

I want to sample fixed N classes in each mini batch, each class has different number of images M_{N}. So in each mini batch, the batch size changes.

I checked the sampler, batchSampler and dataloader fucntions. It seems that I couldn’t do this operation. Any help?