Solved by ptrblck in post #2 
              
              
                If you only have 40 samples, you could probably define the length of your dataset as e.g. 
def __len__(self):
    return 2 * len(self.data)

and use index = index % len(self.data) operation inside __getitem__ to draw the current batch. 
You can pass this dataset to a DataLoader and set shuffle=True …