Repository: pytorch
Issue: torch.is_tensor(obj) doesn't work with JIT, despite the fact that isinstance(obj, Tensor) already works with JIT
Labels: oncall: jit,Stale

## 🐛 Bug

In the documentation for `torch.is_tensor`, it states that the function simply runs `isinstance(obj, Tensor)`

> Note that this function is simply doing isinstance(obj, Tensor). Using that isinstance check is better for typechecking with mypy, and more explicit - so it’s recommended to use that instead of is_tensor.

* https://pytorch.org/docs/stable/generated/torch.is_tensor.html

Therefore `torch.is_tensor(obj)` should work with JIT, but JIT doesn't recognize it.

## To Reproduce

The first function works correctly, but the second one fails despite doing the same thing under the hood:

```
from typing import Union
import torch

def test_isinstance(x: Union[int, torch.Tensor]) -> bool:
      return isinstance(x, torch.Tensor) 
# Works
out = torch.jit.script(test_isinstance)


def test_is_tensor(x: Union[int, torch.Tensor]) -> bool:
      return torch.is_tensor(x)
# Fails
out = torch.jit.script(test_is_tensor)
```

The second function results in the following error message:

```
RuntimeError                              Traceback (most recent call last)

<ipython-input-3-cccc518b00e4> in <module>()
     11       return torch.is_tensor(x)
     12 # Fails
---> 13 out = torch.jit.script(test_is_tensor)

/usr/local/lib/python3.7/dist-packages/torch/jit/_script.py in script(obj, optimize, _frames_up, _rcb, example_inputs)
   1309             _rcb = _jit_internal.createResolutionCallbackFromClosure(obj)
   1310         fn = torch._C._jit_script_compile(
-> 1311             qualified_name, ast, _rcb, get_default_args(obj)
   1312         )
   1313         # Forward docstrings

RuntimeError: 
Unknown builtin op: aten::is_tensor.
Here are some suggestions: 
	aten::as_tensor

The original call is:
  File "<ipython-input-3-cccc518b00e4>", line 11
def test_is_tensor(x: Union[int, torch.Tensor]) -> bool:
      return torch.is_tensor(x)
             ~~~~~~~~~~~~~~~ <--- HERE
```

## Expected behavior

The `torch.is_tensor` function should work with JIT / TorchScript as `isinstance(obj, Tensor)` works.

The `torch.is_tensor` is not listed under unsupported JIT's functions: https://pytorch.org/docs/stable/jit_unsupported.html#jit-unsupported, so I assume the current issue is unintentional.

## Environment

```

Collecting environment information...
PyTorch version: 1.10.0+cu111
Is debug build: False
CUDA used to build PyTorch: 11.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.5 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
CMake version: version 3.12.0
Libc version: glibc-2.26

Python version: 3.7.12 (default, Sep 10 2021, 00:21:48)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.4.104+-x86_64-with-Ubuntu-18.04-bionic
Is CUDA available: False
CUDA runtime version: 11.1.105
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.0.5
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.5
[pip3] torch==1.10.0+cu111
[pip3] torchaudio==0.10.0+cu111
[pip3] torchsummary==1.5.1
[pip3] torchtext==0.11.0
[pip3] torchvision==0.11.1+cu111
[conda] Could not collect
```

Basically the standard Google Colab environment.