is_tensorclass#
- tensordict.is_tensorclass(obj: type | Any) bool#
Returns
Trueifobjis a tensorclass type or an instance of one.Examples
>>> import torch >>> from tensordict import TensorDict, is_tensorclass, tensorclass >>> @tensorclass ... class Data: ... x: torch.Tensor >>> is_tensorclass(Data), is_tensorclass(Data(x=torch.zeros(2))) (True, True) >>> is_tensorclass(TensorDict()) False