Solved by ptrblck in post #4 
              
              
                PyTorch doesn’t have the same isin implementation, but you might take a look at the numpy implementation and maybe use their method? 
Alternatively, you could of course use a list comprehension as: 
x = torch.arange(7)
y = torch.tensor([4, 5, 6])

ret = torch.stack([y_ == x for y_ in y]).sum(0).bool…