I think an even simpler way to do this is to apply the detach() trick. Something like this:
x = something you have
y = -x + (x*2).detach()

Now we can use y instead of x. During backpropation the gradient will pass to x from y in an opposite direction of what it has at y.