Code from: https://github.com/SeitaroShinagawa/simple_beamsearch probs = [[[],[0.3,0.7]], [[0],[0.1,0.9]], [[1],[0.4,0.6]], [[0,0],[0.3,0.7]], [[0,1],[0.8,0.2]], [[1,0],[0.6,0.4]], [[1,1],[0.5,0.5]]] def prob_gen(lis): tmp = [x[1] for x in probs if x…