target = torch.tensor([1.25, 2.5, 3, 1.25, 3])
values = torch.tensor([1.25, 2.5, 3])

I would like to find a fast operation that maps every values in target by their indices in values:
result: torch.tensor([0, 1, 2, 0, 2])

Thanks