Code is:
time1 = time.time()
unique, inv =  torch.unique(src, ,sorted=False, return_inverse=True)
time2 = time.time()
src2 = src.clone()
time2 = time.time()
unique, inv =  torch.unique(src2, sorted=True, return_inverse=True)
time3 = time.time()
print(time2- time1, time3-time2)
get the time:  0.015712261199951172 0.000576972961425781
It’s very strange that time-consuming seems to have nothing to do with whether it is sorted or not. The time-consuming to run first is always higher than  later.