Thanks for replying !! what if the tensor has layout of nchw and I need to remove one element from dim=1 ？
ten = torch.randn(2, 4, 5, 5)
ids = torch.tensor([2, 1, 4, 1])
....
res = ... # should have shape of [2, 3, 5, 5]