Add utility to test if autograd was registered correctly (#106561)
See docstring for more details. This API is not meant to be directly
user-facing, it is meant to be used as a subtest of D47965247, which is
coming soon.
Test Plan:
- Some new tests.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/106561
Approved by: https://github.com/ezyang, https://github.com/soulitzer