I don’t quite understand the second tensor shape and how it corresponds to the index tensor.
However, since the index tensor is using a different number of indices, you would need to either transform the indices to a flattened version (and the same with the original input) or index them separately.