I have a value tensor value.shape=[b, l, c], and an index tesnor index.shape=[b, n], s.t. n<=l, max(n) <= len(l)-1
How to retrieve value tensor by index tensor?

The following code seems to work perfectly but involve a for loop.

torch.stack([value[i, index[i] ]for i in range(len(value))])