[JIT] Fix function schema subtype checking (#47965)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/47965
**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.
Test Plan: Imported from OSS
Reviewed By: qizzzh
Differential Revision: D24970883
fbshipit-source-id: 2e4bda079c7062806c105ffcc14a28796b063525