Confused on how to keep labels paired after using five or TenCrop augmentation

So I was following the five-crop documentation and everything is going great until I am trying to wrap my head around how my labels are going to be synced with input images?

I have a csv file which contains 1 hot encodings, think dogs vs cats. In my dataloader I have batch size of 8 so after five-crop augmentation, I have the batch size of [8, 5, 3, 256, 256]. I then did .view(-1, 3, 256, 256) which then gives me 40 images in a batch, now question is how do I make sure the labels are paired correctly? A quick look at the images shows that they are in order, so I am guessing I need to expand my label from [8] to [8, 5] and collapse it into [40] is this correct? Is this the correct way of doing this? Also how do I duplicate each element in a tensor 5 times so I can have 40 labels?

I think the usual approach would be to average the predictions from the crops and just keep the batch size.
If you really want to extend your batch size, you could try the following:

target = torch.empty(8, dtype=torch.long).random_(10)
target.view(-1, 1).expand(-1, 5).contiguous().view(40)

@ptrblck Okay so that’s why these 2 lines are in five/ten-crop the documentation.

>>> result = model(input.view(-1, c, h, w)) # fuse batch size and ncrops
>>> result_avg = result.view(bs, ncrops, -1).mean(1) # avg over crops