Fix out= variant forward grad detection (#60499)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/60499
Test Plan: Imported from OSS
Reviewed By: mruberry
Differential Revision: D29914595
Pulled By: albanD
fbshipit-source-id: c51bb3aed91ab1f6ebc57936143b249590a43bd5