How to check if a small tensor is inside anthor large tensor

a = torch.tensor([[1,1],[2,2]])
I want to know if tensor([1,1]) is inside in a (return one bool)

a.eq(torch.tensor([1,1]))
tensor([[ True, True],
[False, False]])
→ which should return a True to my case.
a.eq(torch.tensor([1,2]))
tensor([[ True, False],
[False, True]])
→ which should return a false to my case.
Any suggestion?

This should work:

a = torch.tensor([[1,1],[2,2]])
print(a.eq(torch.tensor([1, 1])).all(dim=1).any())
> tensor(True)

print(a.eq(torch.tensor([1,2])).all(dim=1).any())
> tensor(False)
1 Like