Tensor as index

When I run

print(train_y[0])

it returns

tensor([43], device=‘cuda:0’)

When i run

num = train_y[0]
da=data[num]

da is empty. why?

When I run

num=43
da=data[num]

da has data.

Could you recheck the value of num = train_y[0], as this dummy code snippet is running fine?

train_y = torch.tensor([[43], [0]]).cuda()
num = train_y[0]
print(num)

data = torch.randn(50)
print(data[num])
> tensor([-0.2206])
print(data[43])
> tensor(-0.2206)

data exist,

but plot is empty

import matplotlib.pyplot as plt

train_y = torch.tensor([[43], [0]]).cuda()
num = train_y[0]
print(num)

data = torch.randn(50,3)
print(data[num])

plt.figure(0)
plt.plot(data[num])

print(data[43])

plt.figure(1)
plt.plot(data[43])

data[num][0]

THANKS