You can add hooks in the variables (or modules) of the network.
This is explained in this part of the documentation 10.
In your case, you could add a hook in the loss, to change the gradients as you wish.