The error looks to be coming from the DataLoader due to the dataset setup. You could use it as below,
from torch.utils.data import TensorDataset, DataLoader

tr_dataset = TensorDataset(x, y)
trainBa = DataLoader(dataset=tr_dataset, batch_size=10, shuffle=True)