Mapping tensor based on corresponding index tensor

Hi,

I have two tensors of size [b, c, h, w, dim]; one contains values, while other contains indices that these values should map to. I would like to create a third tensor of this dimension and perform the map:
out = value[idx]

How can I do this? I believe index operations like index_copy don’t work with dimensions greater than 1.

Thanks

Could you post an example of the input and index tensors, which shows, how the indexing should work?

value = [[[[[0.4196, 0.4720, 0.4312], [0.7560, 0.2302, 0.0757]],
          [[0.4395, 0.1510, 0.0983], [0.7749, 0.4382, 0.3548]]]]]
idx = [[[[[2, 1, 0], [2, 0, 1]],
          [[0, 1, 2], [0, 1, 2]]]]]

So here I would want a result like:

out = [[[[[0.4312, 0.4720, 0.4196 ], [0.0757, 0.7560, 0.2302]],
          [[0.4395, 0.1510, 0.0983], [0.7749, 0.4382, 0.3548]]]]]