[BE][Ez]: Update torch.is_tensor documentation (#165841)

TypeIs propogates the isinstance check with the typing system. They are now equivalent.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/165841
Approved by: https://github.com/albanD
This commit is contained in:
Aaron Gokaslan
2025-10-19 09:24:08 +00:00
committed by PyTorch MergeBot
parent ceb11a584d
commit 57ba575242

View File

@ -1120,11 +1120,6 @@ def typename(obj: _Any, /) -> str:
def is_tensor(obj: _Any, /) -> _TypeIs["torch.Tensor"]:
r"""Returns True if `obj` is a PyTorch tensor.
Note that this function is simply doing ``isinstance(obj, Tensor)``.
Using that ``isinstance`` check is better for type checking with mypy,
and more explicit - so it's recommended to use that instead of
``is_tensor``.
Args:
obj (object): Object to test
Example::