[JIT] Fix WithTest.test_with_exceptions (#45106)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/45106
**Summary**
This commit fixes `WithTest.test_with_exceptions`. It's been running
in regular Python this whole time; none of the functions created and
invoked for the test were scripted. Fortunately, the tests still pass
after being fixed.
**Test Plan**
Ran unit tests + continuous integration.
Test Plan: Imported from OSS
Reviewed By: gmagogsfm
Differential Revision: D23848206
Pulled By: SplitInfinity
fbshipit-source-id: fd975ee34db9441ef4e4a4abf2fb21298166bbaa