Solved by ptrblck in post #6 
              
              
                You could write a custom Dataset and return the index with the data and target. 
def __getitem__(self, index):
    # your data loading logic
    x = self.data[index]
    y = self.target[index]
   
    # transformations
    ...

    return x, y, index

This would yield an additional batch of the used…