Fix crash in `checkCustomClassType` if arg is null (#69259)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69259
Otherwise `checkCustomClassType(nullptr, new Type())` will crash
Test Plan: Imported from OSS
Reviewed By: lw
Differential Revision: D32775297
Pulled By: malfet
fbshipit-source-id: 54b10fd395d734c615dcaf85a5e599a445cee663