All problems
EOS Handling in Batch
Problem
Update per-sequence finished flags with a batch of end-of-sequence flags. A sequence is finished if it was already finished or just emitted EOS. Return [new_finished, active_count] where active_count counts the sequences still running.
The signature is eos_batch_update(finished, eos_flags).
Hint
Finished sequences are removed from the running batch, freeing their slot.
Test cases
case 1
in: [[false,false],[true,false]]
expected: [[true,false],1]
case 2
in: [[true,true],[false,false]]
expected: [[true,true],0]
case 3
in: [[false],[false]]
expected: [[false],1]
case 4
in: [[false,false,false],[false,false,true]]
expected: [[false,false,true],2]
Starter codePython
def eos_batch_update(finished, eos_flags):
# Your code here
pass4 test cases · run your code against them in the editor