Const-correctness, variable initialization, and error checking. (#42124)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/42124
Test Plan: Imported from OSS
Reviewed By: IvanKobzarev
Differential Revision: D22835543
Pulled By: AshkanAliabadi
fbshipit-source-id: 29b7619b7bc6dd346eec91b8a2b6cc6a76769bcf