fixing autodiff to support Optional[Tensor] on inputs (#49430)
Summary:
This PR fixes two local issue for me:
1. Assert failure when passing `None` to `Optional[Tensor]` input that requires gradient in autodiff
2. Wrong vjp mapping on inputs when `requires_grad` flag changes on inputs stack.
This PR is to support autodiff on layer_norm.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/49430
Reviewed By: izdeby
Differential Revision: D25886211
Pulled By: eellison
fbshipit-source-id: 075af35a4a9c0b911838f25146f859897f9a07a7