def hybrid_forward(self, F, inputs, states=None, mask=None):<EOL>
states_forward, states_backward = states<EOL>if mask is not None:<EOL><INDENT>sequence_length = mask.sum(axis=<NUM_LIT:1>)<EOL><DEDENT>outputs_forward = []<EOL>outputs_backward = []<EOL>for layer_index in range(self._num_layers):<EOL><INDENT>if layer_index == <NUM_LIT:0>:<EOL><INDENT>layer_inputs = inputs<EOL><DEDENT>else:<EOL><INDENT>layer_inputs = outputs_forward[layer_index-<NUM_LIT:1>]<EOL><DEDENT>output, states_forward[layer_index] = F.contrib.foreach(<EOL>self.forward_layers[layer_index],<EOL>layer_inputs,<EOL>states_forward[layer_index])<EOL>outputs_forward.append(output)<EOL>if layer_index == <NUM_LIT:0>:<EOL><INDENT>layer_inputs = inputs<EOL><DEDENT>else:<EOL><INDENT>layer_inputs = outputs_backward[layer_index-<NUM_LIT:1>]<EOL><DEDENT>if mask is not None:<EOL><INDENT>layer_inputs = F.SequenceReverse(layer_inputs,<EOL>sequence_length=sequence_length,<EOL>use_sequence_length=True, axis=<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>layer_inputs = F.SequenceReverse(layer_inputs, axis=<NUM_LIT:0>)<EOL><DEDENT>output, states_backward[layer_index] = F.contrib.foreach(<EOL>self.backward_layers[layer_index],<EOL>layer_inputs,<EOL>states_backward[layer_index])<EOL>if mask is not None:<EOL><INDENT>backward_out = F.SequenceReverse(output,<EOL>sequence_length=sequence_length,<EOL>use_sequence_length=True, axis=<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>backward_out = F.SequenceReverse(output, axis=<NUM_LIT:0>)<EOL><DEDENT>outputs_backward.append(backward_out)<EOL><DEDENT>out = F.concat(*[F.stack(*outputs_forward, axis=<NUM_LIT:0>),<EOL>F.stack(*outputs_backward, axis=<NUM_LIT:0>)], dim=-<NUM_LIT:1>)<EOL>return out, [states_forward, states_backward]<EOL>
Defines the forward computation for cache cell. Arguments can be either
        :py:class:`NDArray` or :py:class:`Symbol`.

        Parameters
        ----------
        inputs : NDArray
            The input data layout='TNC'.
        states : Tuple[List[List[NDArray]]]
            The states. including:
            states[0] indicates the states used in forward layer,
            Each layer has a list of two initial tensors with
            shape (batch_size, proj_size) and (batch_size, hidden_size).
            states[1] indicates the states used in backward layer,
            Each layer has a list of two initial tensors with
            shape (batch_size, proj_size) and (batch_size, hidden_size).

        Returns
        --------
        out: NDArray
            The output data with shape (num_layers, seq_len, batch_size, 2*input_size).
        [states_forward, states_backward] : List
            Including:
            states_forward: The out states from forward layer,
            which has the same structure with *states[0]*.
            states_backward: The out states from backward layer,
            which has the same structure with *states[1]*.