Support Union[NoneType, T] as input type (#51605)
Summary:
ghstack-source-id: 32db9661ce0f9441ef7061285bc24967c2808ea6
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51605
Fixes https://github.com/pytorch/pytorch/issues/51582
=========
In Python 3.9+ Union[T, NoneType] and Union[NoneType, T] as OptionalType.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51606
Test Plan:
====
python test/test_jit.py -v TestJit.test_union_to_optional
Reviewed By: pbelevich
Differential Revision: D26242353
Pulled By: nikithamalgifb
fbshipit-source-id: 0ac441fa1bdf2fb1044e3fe131bee47adda90bbb