def METHOD_NAME(
    self,
    x: torch.Tensor,
    state: Tuple[torch.Tensor, Optional[torch.Tensor]],
) -> Tuple[torch.Tensor, Tuple[torch.Tensor, Optional[torch.Tensor]]]:
    """Encode source label sequences.
    Args:
        x: RNN input sequences. (B, D_emb)
        state: Decoder hidden states. ((N, B, D_dec), (N, B, D_dec) or None)
    Returns:
        x: RNN output sequences. (B, D_dec)
        (h_next, c_next): Decoder hidden states.
                            (N, B, D_dec), (N, B, D_dec) or None)
    """
    h_prev, c_prev = state
    h_next, c_next = self.init_state(x.size(0))
    for layer in range(self.dlayers):
        if self.dtype == "lstm":
            x, (h_next[layer : layer + 1], c_next[layer : layer + 1]) = self.rnn[
                layer
            ](x, hx=(h_prev[layer : layer + 1], c_prev[layer : layer + 1]))
        else:
            x, h_next[layer : layer + 1] = self.rnn[layer](
                x, hx=h_prev[layer : layer + 1]
            )
        x = self.dropout_rnn[layer](x)
    return x, (h_next, c_next)