Akshay_gupta:

    back_hook = 'register_full_backward_hook' if torch.__version__ >= '1.8.0' else 'register_backward_hook'



Also, you don’t want to use register_backward_hook as its behaviour is broken (see this issue here 9)