I don’t quite understand your use case.
Let’s assume you have a tensor x = torch.randn(2, 247, 4).
Now you would like to create an index tensor y containing two values? What do you mean by “whole length corresponds to the size of the 1st dim”?
Do you have two values in y or is it of shape [2, 247]?
If you have two values and index x with y, you would get a tensor of shape [2, 2, 4].
Could you share some pseudo code so that I could have a look and understand the use case a bit better?