dgl.graphbolt.isin(elements, test_elements)[source]ΒΆ

Tests if each element of elements is in test_elements. Returns a boolean tensor of the same shape as elements that is True for elements in test_elements and False otherwise.

  • elements (torch.Tensor) – A 1D tensor represents the input elements.

  • test_elements (torch.Tensor) – A 1D tensor represents the values to test against for each input.


>>> isin(torch.tensor([1, 2, 3, 4]), torch.tensor([2, 3]))
tensor([[False,  True,  True,  False]])