Like if I have a Tensor
a = [1, 2, 2, 3]

If I perform torch.sort(a), then the index it returns will be
[0, 1, 2, 3]

What if I want to get the result like
[0, 1, 1, 3]

I know there’s a function exists in scipy “scipy.data.rankdata”, in the function, I can specify the method it uses when ranking the data. But how can I achieve the similar goal with pytorch?