Hi,
You can use the Tensor hooks directly that will work fine.
In particular, if you add a hook to the input of the sigmoid, you will be able to change the gradient that flow back from there.
I was mentionning the name because the error seems to point to it:
print(‘Backward pass for '+str(name)+'’)

SystemError: <class ‘str’> returned a result with an error set