I have 2 tesnor and I want to create 3rd tensor based on the value of 1st tensor as index in 2nd tensor as below-

a=torch.tensor([8,1,2,3,4,6,5,7,8])

b=torch.tensor([0,1,2,3,4,5,6,7,8])

since 1st value of a=8, 2nd value of a=1… So I want b[8], b[1] and so on… like below.

output= ([8,1,2,3,4,6,5,7,8])

So basically output is tensor b[value of a]. How to do that?