Hello, can you please help with this example
x = torch.rand(10,5)
y = torch.rand(10,4,5)
top_x,top_inds = x.topk(3,dim=-1)
top_y= y.gather(dim=-1,index=top_inds)

and it does not work.

RuntimeError: Index tensor must have the same number of dimensions as input tensor

Currently, I have to work around this by a for-loop:
s_inds = torch.arange(len(x)).long()
top_y = [y[s_inds,:,top_inds[:,i]] for i in range(3)]
top_y = torch.stack(top_y,dim=2)