I think it’s because of the difference between the output of   __getitem__ method of Concated two datasets( train_set and pseudo_set).  __getitem__  of train_set yields (image, int label) while __getitem__ of pseudo_set yields (image, tensor label). After two datasets are concated, a set of indices of the final dataset yields a list of output of __getitem__. But in this case the outputs’ structures probably don’t agree.( (tensor,int) differs from (tensor, tensor)).And Dataloader doesn’t work. However, if you’re lucky enough to have all outputs of identical structure, it will work for a while. The new collate function you define apply longtensor to all targets, which cancels the difference between two kinds of outputs, I guess.
import torch
a = [1,torch.tensor(2)]
print(torch.LongTensor(a))

And this will yield tensor([1, 2]).