def forward(self, inputs, begin_state=None): 
encoded = self.embedding(inputs)<EOL>if begin_state is None:<EOL><INDENT>begin_state = self.begin_state(batch_size=inputs.shape[<NUM_LIT:1>])<EOL><DEDENT>out_states = []<EOL>for i, (e, s) in enumerate(zip(self.encoder, begin_state)):<EOL><INDENT>encoded, state = e(encoded, s)<EOL>out_states.append(state)<EOL>if self._drop_h and i != len(self.encoder)-<NUM_LIT:1>:<EOL><INDENT>encoded = nd.Dropout(encoded, p=self._drop_h, axes=(<NUM_LIT:0>,))<EOL><DEDENT><DEDENT>if self._dropout:<EOL><INDENT>encoded = nd.Dropout(encoded, p=self._dropout, axes=(<NUM_LIT:0>,))<EOL><DEDENT>with autograd.predict_mode():<EOL><INDENT>out = self.decoder(encoded)<EOL><DEDENT>return out, out_states<EOL>
Implement forward computation.

        Parameters
        -----------
        inputs : NDArray
            input tensor with shape `(sequence_length, batch_size)`
            when `layout` is "TNC".
        begin_state : list
            initial recurrent state tensor with length equals to num_layers.
            the initial state with shape `(1, batch_size, num_hidden)`

        Returns
        --------
        out: NDArray
            output tensor with shape `(sequence_length, batch_size, input_size)`
            when `layout` is "TNC".
        out_states: list
            output recurrent state tensor with length equals to num_layers.
            the state with shape `(1, batch_size, num_hidden)`