If you want to implement a custom backward method, you should use autograd.Function and refer to this example 14.
What’s the reason you want to override the backward? Autograd should be able to create the computation graph so that you could return the loss in the forward method and call backward on it.
PS: You can post code snippets by wrapping them into three backticks ```. I’ve edited your post, for easier debugging.