AOTAutograd: fix 'Trying to backward through the graph a second time' error (#98960)
Fixes https://github.com/pytorch/pytorch/issues/97745. See discussion and comment in the PR for more details.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/98960
Approved by: https://github.com/bertmaher, https://github.com/albanD