In fact, for this use case I’d recommend using Sampler. It is meant to define the item picking strategy. So, it is more in line with Pytorch code.
https://pytorch.org/docs/stable/data.html#data-loading-order-and-sampler