Actually, my bad, I just re-read your code and realized it depends on the way you update the i variable, and in your case, it probably wouldn’t work.
Iterations are just a different way of counting than epochs, and the data loader doesn’t care which one you use. However, you need to be careful when counting.
What I recommend doing is transforming your number of iterations into epochs, so that the traditional way of doing PyTorch training is respected (specifically: the shuffling can happen normally in the data loader), but keeping track of the iterations in your training loop (e.g. using the j variable in my short example before as an iteration index for the current epoch).
To conclude: it all depends on your use case, but if you want more iterations than there are mini-batches in the data loader (i.e. more than one epoch’s worth), you need to use the epochs counting system, so that the data loader is shuffled at each epoch.