[mypy] Fix Optional type check (#62668)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/62668
Test Plan: Imported from OSS
Reviewed By: malfet, 842974287
Differential Revision: D30077960
Pulled By: IvanKobzarev
fbshipit-source-id: 5e423bfb65a65974ed848caa177330d6e61452e6