Implement public API InferenceMode and its error handling (#55008)
Summary:
https://www.internalfb.com/phabricator/paste/view/P360377337Pull Request resolved: https://github.com/pytorch/pytorch/pull/53343
For easier review, here's a diff between the version before revert. https://www.internalfb.com/phabricator/paste/view/P360750919
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55008
Test Plan: Imported from OSS
Pulled By: ailzhang
Reviewed By: bhosmer
Differential Revision: D27443229
fbshipit-source-id: 01b03446a1f6373f43dd5c7170d26226b50f363c