avoid redundant isCustomClassRegistered() checks (#42852)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/42852
Test Plan: Imported from OSS
Reviewed By: smessmer
Differential Revision: D23048381
Pulled By: bhosmer
fbshipit-source-id: 40b71670a84cb6f7e5a03279f58ce227d676aa03