Hi,
I just met the same problem as you, and I found torch.scatter_add_() is helpful! You can have a try.
Btw, I found the methods named gather and scatter in PyTorch can solve this kind of problems well, which can be seemed as a “universal” version of methods named index*.