torch.jit.isinstance
torch.jit.isinstance(obj, target_type)
This function provides for container type refinement in
   TorchScript. It can refine parameterized containers of the List,
   Dict, Tuple, and Optional types. E.g. "List[str]", "Dict[str,
   List[torch.Tensor]]", "Optional[Tuple[int,str,int]]". It can also
   refine basic types such as bools and ints that are available in
   TorchScript.
Parameters:
      * obj -- object to refine the type of
  * **target_type** -- type to try to refine obj to

Returns:
      True if obj was successfully refined to the type of target_type,
         False otherwise with no new type refinement
Return type:
      "bool"
Example (using "torch.jit.isinstance" for type refinement): ..
   testcode:
  import torch
  from typing import Any, Dict, List

  class MyModule(torch.nn.Module):
      def __init__(self):
          super(MyModule, self).__init__()
