Pick the best finished beam by length-normalised score score/lenα (a length of 0 counts as 1). beams is a list of (tokens, score) pairs. Ties are broken in favour of the lexicographically smaller token list. alpha must be non-negative and beams must not be empty (otherwise ValueError).
Implement solve(beams, alpha).
Returns. Return the winning (tokens, score) pair.
Example 1
Input:
solve([([1, 2], -3.0), ([3], -1.0)], 1.0)
Output:
([3], -1.0)
Example 2
Input:
solve([([1, 2, 3], -3.0), ([3], -2.0)], 1.0)
Output:
([1, 2, 3], -3.0)
Example 3
Input:
solve([([1, 2, 3], -3.0), ([3], -2.0)], 0.0)
Output:
([3], -2.0)
No results yet
Run your code to check it against the examples, or submit to run every test.