Could you show me an example of what you were thinking?
torch.gather can do something like this (https://pytorch.org/docs/master/torch.html?highlight=gather#torch.gather 213) but it might not be exactly what you’re looking for.