Having the same issue where loss.backward() doesn’t create .grad on the variables that had requires_grad=True. The only reason I can determine is I modified the output used for the loss (this is a necessary step, so I don’t know any way around it), same as your “output_features = …” line.
If you solve, it would be great to post a solution.