It might be easiest to linearize the indices (flattened = tensor.view(-1) and indices = indices_x * tensor.dim(1) + indices_y). Personally, I’d probably use index_add btw.
It’s a bit more clumsy to write, but in the end a multi-dimensional index addition wowuld do the same under the hood (but probably on the fly without materializing the index tensor).
Best regards
Thomas