In your code snippet you are using test to get the data instead of the dataloader:
for i, data in enumerate(test):

which seems to be globally defined and might contain more samples that the wanted dataloader.