how to check whether a certain number is in the Pytorch tensor?
for a Pytorch tensor A:

A = tensor([1,0,0],
           [0,0,0])



is there way I can check whether the number 1 is an element of the tensor A?
like is there a pytorch function that returns True is 1 is an element of A, and returns False if 1 is not an element of A?

Thank you,

torch.Tensor implements __contains__. So, you can just use:

1 in A


This returns True if the element 1 is in A, and False otherwise.
