def decode_seq(self, inputs, states, valid_length=None):
batch_size = inputs.shape[<NUM_LIT:0>]<EOL>length = inputs.shape[<NUM_LIT:1>]<EOL>length_array = mx.nd.arange(length, ctx=inputs.context, dtype=inputs.dtype)<EOL>mask = mx.nd.broadcast_lesser_equal(<EOL>length_array.reshape((<NUM_LIT:1>, -<NUM_LIT:1>)),<EOL>length_array.reshape((-<NUM_LIT:1>, <NUM_LIT:1>)))<EOL>if valid_length is not None:<EOL><INDENT>arange = mx.nd.arange(length, ctx=valid_length.context, dtype=valid_length.dtype)<EOL>batch_mask = mx.nd.broadcast_lesser(<EOL>arange.reshape((<NUM_LIT:1>, -<NUM_LIT:1>)),<EOL>valid_length.reshape((-<NUM_LIT:1>, <NUM_LIT:1>)))<EOL>mask = mx.nd.broadcast_mul(mx.nd.expand_dims(batch_mask, -<NUM_LIT:1>),<EOL>mx.nd.expand_dims(mask, <NUM_LIT:0>))<EOL><DEDENT>else:<EOL><INDENT>mask = mx.nd.broadcast_axes(mx.nd.expand_dims(mask, axis=<NUM_LIT:0>), axis=<NUM_LIT:0>, size=batch_size)<EOL><DEDENT>states = [None] + states<EOL>output, states, additional_outputs = self.forward(inputs, states, mask)<EOL>states = states[<NUM_LIT:1>:]<EOL>if valid_length is not None:<EOL><INDENT>output = mx.nd.SequenceMask(output,<EOL>sequence_length=valid_length,<EOL>use_sequence_length=True,<EOL>axis=<NUM_LIT:1>)<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 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:

            - mem_value : NDArray
            - mem_masks : NDArray, optional
        additional_outputs : list of 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)