[jit] Fix type comparisons segfault (#35929)
Summary:
Pybind will convert `None`s to `nullptr`s, so this adds a check to make
sure those don't get into the actual type comparison logic. Fixes #35778
](https://our.intern.facebook.com/intern/diff/20831278/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35929
Pulled By: driazati
Differential Revision: D20831278
fbshipit-source-id: 5800050e5eec280072afde58141ad00c1e8db8e2