Your loss.data is a “tensor” which is not a vector/matrix anymore but only contains a single value.
Think of it like trying to get an index of a an int in python, which makes no sense right?
E.g.:
a = 3
b = a[0] # <-- getting an index of a single ITEM makes no sense (will crash your program)

To stick as close to the python feel as possible, they implemented this Warning you were getting.