def _UpdateSequenceOutTensorArrays(self, decoder_step_state, time, step_outs,
                                     seq_out_tas):
    """Update SequenceOutTensorArrays at each time step."""
    new_rnn_outs = []
    assert len(seq_out_tas.rnn_outs) == len(decoder_step_state.rnn_states)
    for i in range(len(seq_out_tas.rnn_outs)):
      new_rnn_outs.append(seq_out_tas.rnn_outs[i].write(
          time, decoder_step_state.rnn_states[i].m))
    new_logits_ta = seq_out_tas.logits.write(time, decoder_step_state.logits)
    new_step_outs_ta = seq_out_tas.step_outs.write(time, step_outs)
    new_atten_probs_ta = self._GetNewAttenProbs(seq_out_tas, time,
                                                decoder_step_state)
    new_seq_outs_fusion_states = []
    new_fusion_states_flat = decoder_step_state.fusion_states.Flatten()
    for i in range(len(new_fusion_states_flat)):
      new_seq_outs_fusion_states.append(seq_out_tas.fusion[i].write(
          time, new_fusion_states_flat[i]))
    new_seq_outs_misc_states = []
    new_misc_states_flat = decoder_step_state.misc_states.Flatten()
    for i in range(len(new_misc_states_flat)):
      new_seq_outs_misc_states.append(seq_out_tas.misc[i].write(
          time, new_misc_states_flat[i]))

    return AsrDecoder.SequenceOutTensorArrays(
        rnn_outs=new_rnn_outs,
        step_outs=new_step_outs_ta,
        atten_probs=new_atten_probs_ta,
        logits=new_logits_ta,
        fusion=new_seq_outs_fusion_states,
        misc=new_seq_outs_misc_states)
Update SequenceOutTensorArrays at each time step.
contrib/lingvo-patched-decoder.py