I will both provide some explanation & answer a question on this topic. To my knowledge, when using the beam search to generate text, each of the elements in the tuple generated_outputs.scores contains a matrix, where each row corresponds to each beam, stored at this step, while the values are the sum of log-probas of the previous sequence and the next token. Consequently, here is a snippet of code, which would theoretically allow getting all the beams stored at each step (I use bart-base from facebook checkpoint, although it should not matter):
# Initial beam, which consists of only </s> token with score 1
beams = [[([2], 1)]]
for score_matrix in generated.scores:
    # Add a list, which will contain k most probable beams on this step
    beams.append([])
    # k most probable tokens
    topk = score_matrix.view(-1).topk(4)
    # Get the sum of the log probs (score) of the beam
    topk_scores = topk.values.cpu().detach().numpy()
    # Get the indices of the most probable tokens
    topk_indices = topk.indices.cpu().detach().numpy()
    # Get the tokens ids
    topk_tokens = topk_indices % generated.scores[1].shape[1]
    # Get the indices of the beams, to which these tokens belong
    topk_beams = topk_indices // generated.scores[1].shape[1]
    # For each of k most probable tokens
    for token, nbeam, score in zip(topk_tokens, topk_beams, topk_scores):
        # Take the beam, to which the token belongs
        beam = list(beams[-2][nbeam][0])
        # Add the token to the beam
        beam.append(token)
        # Add the beam and its score
        beams[-1].append((beam, score))

Outputting the last element with [(tokenizer.convert_tokens_to_string(tokenizer.convert_ids_to_tokens(beam_data[0])), beam_data[1])  for beam_data in beams[-1]]results in:
[('</s><s>David Harris has called for the BBC to give back to books.</s></s>.</s>',
  -8.348045),
 ('</s><s>David Harris has called for the BBC to do more to promote books and encourage.</s>',
  -9.903482),
 ('</s><s>David Harris has called for the BBC to do more to promote books. awards to do',
  -10.104368),
 ('</s><s>David Harris has called for the BBC to do more to promote books and authors authors.',
  -10.360886)]

Since I used the default length_penalty=1, to get the true score of the sequence, I do:
generated.sequences_scores.item() * (len(generated_output.sequences[0]) - 1). This score coincides with the score of the most probable beam along the last beams (beam 0), however, the sequences are different. The true sequence outputted with tokenizer.convert_tokens_to_string(tokenizer.convert_ids_to_tokens(generated_output.sequences[0])) results in:
 </s><s>David Harris has called for the BBC to do more to promote books and authors.</s>
Small scrutiny showed that this text, corresponding to the minimum score (i.e. most probable) (</s><s>David Harris has called for the BBC to give back to books.</s></s>.</s>) coincides with the output of the model when length_penalty=0, excluding the last 3 “rubbish” tokens. Here is the output when length_penalty=0:
</s><s>David Harris has called for the BBC to give back to books.</s>
I hope I am missing something here, still it seems pretty vague for me.
May be of interest to @patrickvonplaten