Oh, I just see “torch.LongTensor” is actually a 64 bit tensor (I always confuse these). To do the exact equivalent in terms of types then, you would need to do
y_data_train = torch.tensor(y_train, dtype=torch.long)

or
y_data_train = torch.tensor(y_train, dtype=torch.int64)

(here’s a reference of the different Tensor types: https://pytorch.org/docs/stable/tensors.html#torch-tensor 1)