How to index a tensor by a tensor

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))])
value[torch.arange(len(index)), index.T].transpose(0,1)

@zyc you can use this

enhanced_index = torch.Tensor([[i, y] for i,x in enumerate(index) for y in x]).type(torch.long)
values[enhanced_index[:,0], enhanced_index[:,1]]