MarianMT = How to return 5 best candidates for a translation.  
This is a code for normal translation. This is the most probable translation. How can I return lets says 5 best candidates for translation for every single word (beam size would be 1)?

This model only return just the best word, which gives us a better translation. But I want to use it as a language model.

Is this even possible. I was looking at classes and code but I am not sure how would I do it.

    

    from transformers import MarianMTModel, MarianTokenizer
    src_text = [
        '>>fr<< this is a sentence in english that we want to translate to french',
    ]    
    model_name = 'Helsinki-NLP/opus-mt-en-ROMANCE'
    tokenizer = MarianTokenizer.from_pretrained(model_name)
    print(tokenizer.supported_language_codes)
    model = MarianMTModel.from_pretrained(model_name)
    translated = model.generate(**tokenizer.prepare_translation_batch(src_text))
    tgt_text = [tokenizer.decode(t, skip_special_tokens=True) for t in translated]
That is available on this page - https://marian-nmt.github.io/faq:

Can I generate n-best lists?
 Yes. Just use --n-best and the set --beam-size 6 for an n-best list size of 6.

I do not know how to apply it here.<|||||>That feature is not supported in our implementation, unfortunately.<|||||>This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
<|||||>You can try passing `num_return_sequences=5` to generate, but that behavior is untested, and I have never used it.<|||||>> You can try passing `num_return_sequences=5` to generate, but that behavior is untested, and I have never used it.

However, do not forget to set the beams accordingly. The beams must be defined at least as large as the desired number of alternative results.