HI, thanks for replying this. In my case, the ids is not a (2, ) index tensor, it has shape of (2, 5, 5).
ten = torch.randn(2, 4, 5, 5)
ids = torch.randint(0, 4, (2, 5, 5))
.....
res = ... # has shape of (2, 3, 5, 5)

I am afraid there should not be broadcast operation here. The (2, 5, 5) tensor of ids means that the element of the [:, id, :, :] should be removed according to the ids.
How could I do this please?