extracting subtensor from a tensor according to an index tensor
I have this tensor:
tensor([[[1, 2],
         [3, 4]],
        [[5, 6],
         [7, 8]]])

and I have this index tensor:
tensor([0, 1])

and what I want to get is the subtensors according to dim 1 and the corresponding indices in the index tensor, that is:
tensor([[1, 2],
        [7, 8]])

tried to use torch.gather() function and advanced indexing with no success, can anyone help?

You are implicitly using the index of each value of your index tensor.  They just happen to be the same as the values.  If you want to walk through the first level, elements of the tensor, you can use torch.arange to construct the first level indices.
import torch
from torch import tensor

t = tensor([[[1, 2],
             [3, 4]],
            [[5, 6],
             [7, 8]]])

ix = tensor([0, 1])
ix0 = torch.arange(0, ix.shape.numel())

t[ix0, ix]
# returns:
tensor([[1, 2],
        [7, 8]])

