If you want to change the dtype, you can directly pass the wanted dtype to the to() call:
x = x.to(torch.float32)
x = x.to(torch.long)

or call the “dtype method” on the tensor:
x = x.float()
x = x.long()