That is why I was adding the second example @bhanu. If you are iterating over the dataset:
for image, labels in dataloader:
    pass

You are ensured that the dataloader will visit EVERY single image (a full epoch). If you want to make your training iterations shorter than epochs, then you could do something like this:
N = len(data_loader) # length of your dataset
M = 100              # iteration length
T = 10               # total number of iterations
# Get iterator
iterator = iter(dataloader) # iter -> triggers __iter__() -> shuffles data
current = 0
for _ in range(T): # loop over number of iterations
    for _ in range(M): # your iteration length
        images, labels = next(iterator)  # grab next batch

        # do your batch thingy

        current += 1
        if current >= N:
            # we arrived to the end of the iterator -- reshuffle
            current = 0
            iterator = iter(dataloader) # iter -> triggers __iter__() -> shuffles data

    # End of iteration, save your "iteration stats"

In the above example, since you only grabbing the iterator of a dataset once outside the loop, all your inner loop iterations are ensured to go through all your data in random order.