support optional comparisons with different but comparable types (#62890)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/62565
Pull Request resolved: https://github.com/pytorch/pytorch/pull/62890
Reviewed By: ejguan
Differential Revision: D30396008
Pulled By: dagitses
fbshipit-source-id: fca02207509f882973d54484f89c4d116505fc66