Fix full backward hook when grad is disabled (#65335)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/59901. See discussion in the issue.
cc albanD soulitzer
Pull Request resolved: https://github.com/pytorch/pytorch/pull/65335
Reviewed By: malfet
Differential Revision: D31055865
Pulled By: albanD
fbshipit-source-id: 53605df62bc73c99d8908248087ab400b81ac495