Debugging `terminate called after throwing an instance of 'python_error'`

I’m using PyTorch’s new register_full_backward_hook and getting this error without no error message:

terminate called after throwing an instance of 'python_error'
  what():
Aborted

How do I debug this???

You could run the script in gdb and check the backtrace via:

gdb --args python script.py args
...
run
...
bt

This should point towards to failing operation.