[JIT] Fix function schema subtype checking (#47706)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/47706
**Summary**
This commit fixes `FunctionSchema::isSubtypeOf` so that the subtyping rule it
implements for `FunctionSchema` instances is contravariant in argument
types and covariant in return type. At present, the rule is covariant in
argument types and contravariant in return type, which is not correct.
A brief but not rigourous explanation follows. Suppose there are two
`FunctionSchema`s, `M = (x: T) -> R` and `N = (x: U) -> S`. For `M <= N`
to be true (i.e. that `M` is a subtype of `N`), it must be true that `U
<= T` and `R <= S`. This generalizes to functions with multiple
arguments.
**Test Plan**
This commit extends `TestModuleInterface.test_module_interface_subtype`
with two new tests cases that test the contravariance of argument types
and covariance of return types in determining whether a `Module`
implements an interface type.
**Fixes**
This commit closes #47631.
Test Plan: Imported from OSS
Reviewed By: nikithamalgifb
Differential Revision: D24934099
Pulled By: SplitInfinity
fbshipit-source-id: bd07e7b47d2a3a56d676f2f572de09fb18ececd8