A bug with subscript while maintaining beam_indices.
#### This is the position with this bug: https://github.com/huggingface/transformers/blob/31d452c68b34c2567b62924ee0df40a83cbc52d5/src/transformers/generation/utils.py#L2875
#### The problem caused by this bug:
I want to get all decoder_hidden_states (with dimension [max_seq_len * (1 + decoder_layers) * (num_beam * batch_size) * embedding_size]) and beam_indices to keep track of those hidden states of each word generated.
After some example early stop (\<eos\> is generated), some beam_indices will become zero incorrectly. This bug is caused by the wrong subscript (`beam_indices[beam_idx[i]]`) when the model update the beam_indices and it should be `beam_indices[i]`.
cc @gante, but note that there is little we can do to help without a reproducer of the bug.<|||||>Hey @aj666aj 👋 

Can I have a script to reproduce your problem? I'll struggle to pinpoint the issue without it, which will make me deprioritize this issue :)<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.