Hi,
I think you have two things called loss here that are confusing.
The loss in your code is actually the loss module you defined. You need to call it with the input to get the loss value from your batch. Then you will be able to call .backward() on that.