def decode_seq(self, inputs, states, valid_length=None):
length = inputs.shape[<NUM_LIT:1>]<EOL>output = []<EOL>additional_outputs = []<EOL>inputs = _as_list(mx.nd.split(inputs, num_outputs=length, axis=<NUM_LIT:1>, squeeze_axis=True))<EOL>rnn_states_l = []<EOL>attention_output_l = []<EOL>fixed_states = states[<NUM_LIT:2>:]<EOL>for i in range(length):<EOL><INDENT>ele_output, states, ele_additional_outputs = self.forward(inputs[i], states)<EOL>rnn_states_l.append(states[<NUM_LIT:0>])<EOL>attention_output_l.append(states[<NUM_LIT:1>])<EOL>output.append(ele_output)<EOL>additional_outputs.extend(ele_additional_outputs)<EOL><DEDENT>output = mx.nd.stack(*output, axis=<NUM_LIT:1>)<EOL>if valid_length is not None:<EOL><INDENT>states = [_nested_sequence_last(rnn_states_l, valid_length),<EOL>_nested_sequence_last(attention_output_l, valid_length)] + fixed_states<EOL>output = mx.nd.SequenceMask(output,<EOL>sequence_length=valid_length,<EOL>use_sequence_length=True,<EOL>axis=<NUM_LIT:1>)<EOL><DEDENT>if self._output_attention:<EOL><INDENT>additional_outputs = [mx.nd.concat(*additional_outputs, dim=-<NUM_LIT:2>)]<EOL><DEDENT>return output, states, additional_outputs<EOL>
Decode the decoder inputs. This function is only used for training.

        Parameters
        ----------
        inputs : NDArray, Shape (batch_size, length, C_in)
        states : list of NDArrays or None
            Initial states. The list of initial decoder states
        valid_length : NDArray or None
            Valid lengths of each sequence. This is usually used when part of sequence has
            been padded. Shape (batch_size,)

        Returns
        -------
        output : NDArray, Shape (batch_size, length, C_out)
        states : list
            The decoder states, includes:

            - rnn_states : NDArray
            - attention_vec : NDArray
            - mem_value : NDArray
            - mem_masks : NDArray, optional
        additional_outputs : list
            Either be an empty list or contains the attention weights in this step.
            The attention weights will have shape (batch_size, length, mem_length) or
            (batch_size, num_heads, length, mem_length)