Use this example as reference. You can call them outside the for loop by creating iters
a = torch.tensor([1., 2, 3])
class Dataset(torch.utils.data.Dataset):
    def __init__(self, x):
        self.x = x
    def __len__(self):
        return self.x.size(0)
    def __getitem__(self, idx):
        return self.x[idx]
dataset = Dataset(a)
loader = torch.utils.data.DataLoader(dataset)

i_loader = iter(loader)
for i in range(10):
    try:
        a = next(i_loader)
        print(a)
    except StopIteration:
        i_loader = iter(loader)

tensor([1.])
tensor([2.])
tensor([3.])
tensor([1.])
tensor([2.])
tensor([3.])
tensor([1.])
tensor([2.])