This question may be basic and there may be a simple good way,

but I took not short time for this.

I want to silice tensor by another tensor.

Suppose we have a tensor of size [num_grid, num_box, len(x, y, w, h)]

in the situation that all grids has some boxes and its coodinates,

and a tensor of size [num_grid] which means that each index is the maximum IoU box for each grid.

Is there a good way to obtain a tensor of size [num_grid, len(x, y, w, h)]

the tensor of the highest IoU box for each grid?

Thank you.