I think I got what the problem is, you should check that the inputs to the function that calculates the loss are the same sire so that it can actually calculate a loss.
You would nee to use the debugger and check that both tensors have the same size. (tensor.size)