Thank you for your answer.
The only question that remains is how such indices help when training in batches? My understanding is that the total loss value at the output is the mean of individual loss values for each sample in the minibatch.
With your explanation, it sounds like we need to backpropagate the loss value for each individual sample in the minibatch so that we can decide which indices should have a zero gradient and which ones should be multiplied by one.
P.S. In the source code, the name of the function includes single_out_frame, which might mean that in fact, the samples are processed one at a time during the backward pass.