Why I am getting "AttributeError: 'Tensor' object has no attribute 'train_img' "

For splitting you data into train, validation and test, you can use Dataset and DataLoader. Please see Torch.utils.data.dataset.random_split for example.