step() should be called on the optimizer, not on the loss. It’s fine if you defined the loss yourself, as long as it’s the outcome of operations between Variables, you can call backward() on it.
Can you specify what does not satisfy your needs in the code I wrote? The thing is I’m not really sure what you intend to do…