fix optional type promotion for classes (#21593)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/21593
ghimport-source-id: f68730618bccf2326218e08d0a2a70171fdd8921
Differential Revision: D15741471
Pulled By: suo
fbshipit-source-id: 7ac1a0f6d9d2ff4bc819caff43a7a5b6d37cbc98