[JIT] Allow self-referential annotations in classes (#39821)
Summary:
**Summary**
This commit adds support for annotations in method signatures of a
TorchScript class types that refer to the class being defined itself.
**Test Plan**
This commit adds a unit test to check that a method that uses
self-referential type annotations can be defined and produces the same
results in Python and TorchScript.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/39821
Differential Revision: D22003624
Pulled By: SplitInfinity
fbshipit-source-id: dce921c2e0ca0c8aecb52d5b0646b419eb207146