Let me know if this is what you want:
You have a loss function that returns positive and negative losses. You want to minimize positive losses as well as the negative losses.
I think you can define an overall loss that sums together all of those losses. You can call backward() on that, and then send the gradients into an optimizer.