Thanks for your advice!  I implemented it with a batch sampler which defines the batches based on some conditionals (ref: But what are PyTorch DataLoaders really? | Scott Condron’s Blog 2) which works well.