I solved the problem, I noticed that I was not transforming to tensor after resizing…so after changing my resize class, the problem was solved:
class resize:
    def __call__(self, sample):
        inputs,targets = sample
        inputs=transforms.ToPILImage()(inputs)
        inputs =torchvision.transforms.functional.resize(inputs, (120,120), interpolation=2)
        inputs=transforms.ToTensor()(inputs)
        return inputs,targets

but now I have another question…
why I got error when I was using transforms in my dataset class?
class swe_dataset(Dataset):
    def __init__(self, train, label,transform=None):
        self.x_data=train 
        self.y_data=label
        self.len = len(self.x_data)
        #self.transform=transform
        
        self.transform= transforms.Compose([
            transforms.ToPILImage(),
            transforms.Resize((120,120)),
            transforms.ToTensor()
        ])

while I was doing the same thing when I used my resize class, it worked well…
why it didnt work when I used transforms in dataset class?