def init_state_from_encoder(self, encoder_outputs, encoder_valid_length=None):
mem_value = encoder_outputs<EOL>decoder_states = [mem_value]<EOL>mem_length = mem_value.shape[<NUM_LIT:1>]<EOL>if encoder_valid_length is not None:<EOL><INDENT>dtype = encoder_valid_length.dtype<EOL>ctx = encoder_valid_length.context<EOL>mem_masks = mx.nd.broadcast_lesser(<EOL>mx.nd.arange(mem_length, ctx=ctx, dtype=dtype).reshape((<NUM_LIT:1>, -<NUM_LIT:1>)),<EOL>encoder_valid_length.reshape((-<NUM_LIT:1>, <NUM_LIT:1>)))<EOL>decoder_states.append(mem_masks)<EOL><DEDENT>self._encoder_valid_length = encoder_valid_length<EOL>return decoder_states<EOL>
Initialize the state from the encoder outputs.

        Parameters
        ----------
        encoder_outputs : list
        encoder_valid_length : NDArray or None

        Returns
        -------
        decoder_states : list
            The decoder states, includes:

            - mem_value : NDArray
            - mem_masks : NDArray, optional