According to https://stackoverflow.com/questions/64300830/pytorch-tensor-get-the-index-of-the-element-with-specific-values 1, this is a way to do it:
a = torch.IntTensor([1,3,2,1,4,2])
b=[2,1,6]
mask = torch.zeros(a.shape).type(torch.bool)
for e in b:
…mask = mask + (a == e)
torch.nonzero(mask).squeeze_(1) # tensor([0, 2, 3, 5])