[JIT] adding torch.jit.isinstance support (#46062)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/46062
Adds support for torch.jit.isinstance in both eager and script mode
Example use:
```
import torch
from typing import Any, List
class TestModule(torch.nn.Module):
def __init__(self):
super(TestModule, self).__init__()
def call(self, input1: str, input2: str) -> str:
return input1
def forward(self, input: Any) -> None:
if torch.jit.isinstance(input, List[str]):
for el in input:
print(el)
TestModule().forward(["1","2"])
scripted_module = torch.jit.script(TestModule())
scripted_module(["1", "2"])
```
Test Plan: Imported from OSS
Reviewed By: bertmaher, zou3519
Differential Revision: D24264415
Pulled By: Lilyjjo
fbshipit-source-id: 039c95bddd854c414027ac8332832e6bc830b5b9