AOTAutograd: Go down inference path if no outputs require grad (#111011)
Fixes https://github.com/pytorch/pytorch/issues/110666
Slight update to original PR here: https://github.com/pytorch/pytorch/pull/111005
Pull Request resolved: https://github.com/pytorch/pytorch/pull/111011
Approved by: https://github.com/Chillee