Hi,
It is my fault that I did not describe correctly. What I would like to do is like this:
For example, the inputs are:
ind = torch.tensor([3,5,7,8])
a = torch.tensor([5,5,5,8,8,3,7,3,7])

Here values in ind is unique, but values in a is not unique.
And the expected output is like this:
out = torch.tensor([1,1,1,3,3,0,2,0,2])

I did not mean to do this in sequential way, my implementation above is wrong. Do I have a good way to do this please?