Considering the full example.
I am not sure to understand what are the indices supposed to index if the indices tensor has the same size as the input? Also is the original value you want to apply the “max” with always a Tensor full of zeros?