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)

tensor([[ True, True],
[False, False]])
–> which should return a True to my case.

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)

> tensor(False)
1 Like