code: def _docs_rnn():
      _docs.set_doc(
          chainerx.n_step_lstm,
          """n_step_lstm(n_layers, hx, cx, ws, bs, xs)
      Stacked Uni-directional Long Short-Term Memory function.
  
  This function calculates stacked Uni-directional LSTM with sequences.
  This function gets an initial hidden state :math:`h_0`, an initial cell
  state :math:`c_0`, an input sequence :math:`x`, weight matrices :math:`W`,
  and bias vectors :math:`b`.
  This function calculates hidden states :math:`h_t` and :math:`c_t` for each
  time :math:`t` from input :math:`x_t`.
  
  .. math::
     i_t &= \\sigma(W_0 x_t + W_4 h_{t-1} + b_0 + b_4) \\\\
     f_t &= \\sigma(W_1 x_t + W_5 h_{t-1} + b_1 + b_5) \\\\
     o_t &= \\sigma(W_2 x_t + W_6 h_{t-1} + b_2 + b_6) \\\\
     a_t &= \\tanh(W_3 x_t + W_7 h_{t-1} + b_3 + b_7) \\\\
     c_t &= f_t \\cdot c_{t-1} + i_t \\cdot a_t \\\\
     h_t &= o_t \\cdot \\tanh(c_t)
  
  As the function accepts a sequence, it calculates :math:`h_t` for all
  :math:`t` with one call. Eight weight matrices and eight bias vectors are
  required for each layer. So, when :math:`S` layers exist, you need to
  prepare :math:`8S` weight matrices and :math:`8S` bias vectors.
  If the number of layers ``n_layers`` is greater than :math:`1`, the input
  of the ``k``-th layer is the hidden state ``h_t`` of the ``k-1``-th layer.
  Note that all input variables except the first layer may have different
  shape from the first layer.
  
  Args:
      n_layers(int): The number of layers.
      hx (:class:`~chainerx.array`):
          Variable holding stacked hidden states.
          Its shape is ``(S, B, N)`` where ``S`` is the number of layers and
          is equal to ``n_layers``, ``B`` is the mini-batch size, and ``N``
          is the dimension of the hidden units.
      cx (:class:`~chainerx.array`): Variable holding stacked cell states.
          It has the same shape as ``hx``.
      ws (list of list of :class:`~chainerx.array`): Weight matrices.
          ``ws[i]`` represents the weights for the i-th layer.
          Each ``ws[i]`` is a list containing eight matrices.
          ``ws[i][j]`` corresponds to :math:`W_j` in the equation.
          Only ``ws[0][j]`` where ``0 <= j < 4`` are ``(N, I)``-shaped as
          they are multiplied with input variables, where ``I`` is the size
          of the input and ``N`` is the dimension of the hidden units. All
          other matrices are ``(N, N)``-shaped.
      bs (list of list of :class:`~chainerx.array`): Bias vectors.
          ``bs[i]`` represents the biases for the i-th layer.
          Each ``bs[i]`` is a list containing eight vectors.
          ``bs[i][j]`` corresponds to :math:`b_j` in the equation.
          The shape of each matrix is ``(N,)`` where ``N`` is the dimension
          of the hidden units.
      xs (list of :class:`~chainerx.array`):
          A list of :class:`~chainerx.array`
          holding input values. Each element ``xs[t]`` holds input value
          for time ``t``. Its shape is ``(B_t, I)``, where ``B_t`` is the
          mini-batch size for time ``t``.
          When sequences has different lengths, they must be
          sorted in descending order of their lengths.
          So ``xs`` needs to satisfy
          ``xs[t].shape[0] >= xs[t + 1].shape[0]``.
  
  Returns:
      tuple: This function returns a tuple containing three elements,
      ``hy``, ``cy`` and ``ys``.
  
      - ``hy`` is an updated hidden states whose shape is the same as
        ``hx``.
      - ``cy`` is an updated cell states whose shape is the same as
        ``cx``.
      - ``ys`` is a list of :class:`~chainerx.array` . Each element
        ``ys[t]`` holds hidden states of the last layer corresponding
        to an input ``xs[t]``. Its shape is ``(B_t, N)`` where ``B_t`` is
        the mini-batch size for time ``t``, and ``N`` is size of hidden
        units. Note that ``B_t`` is the same value as ``xs[t]``.
  
  .. note::
     The dimension of hidden units is limited to only one size ``N``. If you
     want to use variable dimension of hidden units, please use
     :class:`chainerx.lstm`.
  
  .. seealso::
     :func:`chainerx.lstm`
  
  .. admonition:: Example
  
      >>> import chainerx as chx
      >>> batchs = [3, 2, 1]  # support variable length sequences
      >>> in_size, out_size, n_layers = 3, 2, 2
      >>> xs = [chx.ones((b, in_size)).astype(chx.float32) for b in batchs]
      >>> [x.shape for x in xs]
      [(3, 3), (2, 3), (1, 3)]
      >>> h_shape = (n_layers, batchs[0], out_size)
      >>> hx = chx.ones(h_shape).astype(chx.float32)
      >>> cx = chx.ones(h_shape).astype(chx.float32)
      >>> w_in = lambda i, j: in_size if i == 0 and j < 4 else out_size
      >>> ws = []
      >>> bs = []
      >>> for n in range(n_layers):
      ...     ws.append([chx.ones((out_size, w_in(n, i))).\
  astype(np.float32) for i in range(8)])
      ...     bs.append([chx.ones((out_size,)).astype(chx.float32) \
  for _ in range(8)])
      ...
      >>> ws[0][0].shape  # ws[0][:4].shape are (out_size, in_size)
      (2, 3)
      >>> ws[1][0].shape  # others are (out_size, out_size)
      (2, 2)
      >>> bs[0][0].shape
      (2,)
      >>> hy, cy, ys = chx.n_step_lstm(
      ...     n_layers, hx, cx, ws, bs, xs)
      >>> hy.shape
      (2, 3, 2)
      >>> cy.shape
      (2, 3, 2)
      >>> [y.shape for y in ys]
      [(3, 2), (2, 2), (1, 2)]
  """,
      )
  
      _docs.set_doc(
          chainerx.n_step_bilstm,
          """n_step_bilstm(n_layers, hx, cx, ws, bs, xs)
  Stacked Bi-directional Long Short-Term Memory function.
  This function calculates stacked Bi-directional LSTM with sequences.
  This function gets an initial hidden state :math:`h_0`, an initial cell
  state :math:`c_0`, an input sequence :math:`x`, weight matrices :math:`W`,
  and bias vectors :math:`b`.
  This function calculates hidden states :math:`h_t` and :math:`c_t` for each
  time :math:`t` from input :math:`x_t`.
  
  .. math::
      i^{f}_t &=& \\sigma(W^{f}_0 x_t + W^{f}_4 h_{t-1} + b^{f}_0 + b^{f}_4),
      \\\\
      f^{f}_t &=& \\sigma(W^{f}_1 x_t + W^{f}_5 h_{t-1} + b^{f}_1 + b^{f}_5),
      \\\\
      o^{f}_t &=& \\sigma(W^{f}_2 x_t + W^{f}_6 h_{t-1} + b^{f}_2 + b^{f}_6),
      \\\\
      a^{f}_t &=& \\tanh(W^{f}_3 x_t + W^{f}_7 h_{t-1} + b^{f}_3 + b^{f}_7),
      \\\\
      c^{f}_t &=& f^{f}_t \\cdot c^{f}_{t-1} + i^{f}_t \\cdot a^{f}_t,
      \\\\
      h^{f}_t &=& o^{f}_t \\cdot \\tanh(c^{f}_t),
      \\\\
      i^{b}_t &=& \\sigma(W^{b}_0 x_t + W^{b}_4 h_{t-1} + b^{b}_0 + b^{b}_4),
      \\\\
      f^{b}_t &=& \\sigma(W^{b}_1 x_t + W^{b}_5 h_{t-1} + b^{b}_1 + b^{b}_5),
      \\\\
      o^{b}_t &=& \\sigma(W^{b}_2 x_t + W^{b}_6 h_{t-1} + b^{b}_2 + b^{b}_6),
      \\\\
      a^{b}_t &=& \\tanh(W^{b}_3 x_t + W^{b}_7 h_{t-1} + b^{b}_3 + b^{b}_7),
      \\\\
      c^{b}_t &=& f^{b}_t \\cdot c^{b}_{t-1} + i^{b}_t \\cdot a^{b}_t, \\\\
      h^{b}_t &=& o^{b}_t \\cdot \\tanh(c^{b}_t), \\\\
      h_t &=& [h^{f}_t; h^{b}_t]
  
  where :math:`W^{f}` is the weight matrices for forward-LSTM, :math:`W^{b}`
  is weight matrices for backward-LSTM.
  As the function accepts a sequence, it calculates :math:`h_t` for all
  :math:`t` with one call. Eight weight matrices and eight bias vectors are
  required for each layer of each direction. So, when :math:`S` layers
  exist, you need to prepare :math:`16S` weight matrices and :math:`16S`
  bias vectors.
  If the number of layers ``n_layers`` is greater than :math:`1`, the input
  of the ``k``-th layer is the hidden state ``h_t`` of the ``k-1``-th layer.
  Note that all input variables except the first layer may have different
  shape from the first layer.
  
  Args:
      n_layers(int): The number of layers.
      hx (:class:`~chainerx.array`):
          Variable holding stacked hidden states.
          Its shape is ``(2S, B, N)`` where ``S`` is the number of layers and
          is equal to ``n_layers``, ``B`` is the mini-batch size, and ``N``
          is the dimension of the hidden units. Because of bi-direction, the
          first dimension length is ``2S``.
      cx (:class:`~chainerx.array`): Variable holding stacked cell states.
          It has the same shape as ``hx``.
      ws (list of list of :class:`~chainerx.array`): Weight matrices.
          ``ws[2 * l + m]`` represents the weights for the l-th layer of
          the m-th direction. (``m == 0`` means the forward direction and
          ``m == 1`` means the backward direction.) Each ``ws[i]`` is a
          list containing eight matrices. ``ws[i][j]`` corresponds to
          :math:`W_j` in the equation. ``ws[0][j]`` and ``ws[1][j]`` where
          ``0 <= j < 4`` are ``(N, I)``-shaped because they are multiplied
          with input variables, where ``I`` is the size of the input.
          ``ws[i][j]`` where ``2 <= i`` and ``0 <= j < 4`` are
          ``(N, 2N)``-shaped because they are multiplied with two hidden
          layers :math:`h_t = [h^{f}_t; h^{b}_t]`. All other matrices are
          ``(N, N)``-shaped.
      bs (list of list of :class:`~chainerx.array`): Bias vectors.
          ``bs[2 * l + m]`` represents the weights for the l-th layer of
          m-th direction. (``m == 0`` means the forward direction and
          ``m == 1`` means the backward direction.)
          Each ``bs[i]`` is a list containing eight vectors.
          ``bs[i][j]`` corresponds to :math:`b_j` in the equation.
          The shape of each matrix is ``(N,)``.
      xs (list of :class:`~chainerx.array`):
          A list of :class:`~chainerx.array`
          holding input values. Each element ``xs[t]`` holds input value
          for time ``t``. Its shape is ``(B_t, I)``, where ``B_t`` is the
          mini-batch size for time ``t``.
          When sequences has different lengths, they must be
          sorted in descending order of their lengths.
          So ``xs`` needs to satisfy
          ``xs[t].shape[0] >= xs[t + 1].shape[0]``.
  
  Returns:
      tuple: This function returns a tuple containing three elements,
      ``hy``, ``cy`` and ``ys``.
  
      - ``hy`` is an updated hidden states whose shape is the same as
        ``hx``.
      - ``cy`` is an updated cell states whose shape is the same as
        ``cx``.
      - ``ys`` is a list of :class:`~chainer.array` . Each element
        ``ys[t]`` holds hidden states of the last layer corresponding
        to an input ``xs[t]``. Its shape is ``(B_t, 2N)`` where ``B_t``
        is the mini-batch size for time ``t``, and ``N`` is size of
        hidden units. Note that ``B_t`` is the same value as ``xs[t]``.
  
  .. admonition:: Example
  
      >>> import chainerx as chx
      >>> batchs = [3, 2, 1]  # support variable length sequences
      >>> in_size, out_size, n_layers = 3, 2, 2
      >>> dropout_ratio = 0.0
      >>> xs = [chx.ones((b, in_size)).astype(chx.float32) for b in batchs]
      >>> [x.shape for x in xs]
      [(3, 3), (2, 3), (1, 3)]
      >>> h_shape = (n_layers * 2, batchs[0], out_size)
      >>> hx = chx.ones(h_shape).astype(chx.float32)
      >>> cx = chx.ones(h_shape).astype(chx.float32)
      >>> def w_in(i, j):
      ...     if i == 0 and j < 4:
      ...         return in_size
      ...     elif i > 0 and j < 4:
      ...         return out_size * 2
      ...     else:
      ...         return out_size
      ...
      >>> ws = []
      >>> bs = []
      >>> for n in range(n_layers):
      ...     for direction in (0, 1):
      ...         ws.append([chx.ones((out_size, w_in(n, i))).\
  astype(np.float32) for i in range(8)])
      ...         bs.append([chx.ones((out_size,)).astype(chx.float32) \
  for _ in range(8)])
      ...
      >>> ws[0][0].shape  # ws[0:2][:4].shape are (out_size, in_size)
      (2, 3)
      >>> ws[2][0].shape  # ws[2:][:4].shape are (out_size, 2 * out_size)
      (2, 4)
      >>> ws[0][4].shape  # others are (out_size, out_size)
      (2, 2)
      >>> bs[0][0].shape
      (2,)
      >>> hy, cy, ys = chx.n_step_bilstm(
      ...     n_layers, hx, cx, ws, bs, xs)
      >>> hy.shape
      (4, 3, 2)
      >>> cy.shape
      (4, 3, 2)
      >>> [y.shape for y in ys]
      [(3, 4), (2, 4), (1, 4)]
      """,
      )
  
      _docs.set_doc(
          chainerx.n_step_gru,
          """n_step_gru(n_layers, hx, ws, bs, xs)
  Stacked Uni-directional Gated Recurrent Unit function.
  This function calculates stacked Uni-directional GRU with sequences.
  This function gets an initial hidden state :math:`h_0`, an input
  sequence :math:`x`, weight matrices :math:`W`, and bias vectors :math:`b`.
  This function calculates hidden states :math:`h_t` for each time :math:`t`
  from input :math:`x_t`.
  
  .. math::
     r_t &= \\sigma(W_0 x_t + W_3 h_{t-1} + b_0 + b_3) \\\\
     z_t &= \\sigma(W_1 x_t + W_4 h_{t-1} + b_1 + b_4) \\\\
     h'_t &= \\tanh(W_2 x_t + b_2 + r_t \\cdot (W_5 h_{t-1} + b_5)) \\\\
     h_t &= (1 - z_t) \\cdot h'_t + z_t \\cdot h_{t-1}
  
  As the function accepts a sequence, it calculates :math:`h_t` for all
  :math:`t` with one call. Six weight matrices and six bias vectors are
  required for each layers. So, when :math:`S` layers exists, you need to
  prepare :math:`6S` weight matrices and :math:`6S` bias vectors.
  If the number of layers ``n_layers`` is greather than :math:`1`, input
  of ``k``-th layer is hidden state ``h_t`` of ``k-1``-th layer.
  Note that all input variables except first layer may have different shape
  from the first layer.
  
  Args:
      n_layers(int): Number of layers.
      hx (~chainerx.array):
          Variable holding stacked hidden states.
          Its shape is ``(S, B, N)`` where ``S`` is number of layers and is
          equal to ``n_layers``, ``B`` is mini-batch size, and ``N`` is
          dimension of hidden units.
      ws (list of list of :class:`~chainerx.array`): Weight matrices.
          ``ws[i]`` represents weights for i-th layer.
          Each ``ws[i]`` is a list containing six matrices.
          ``ws[i][j]`` is corresponding with ``W_j`` in the equation.
          Only ``ws[0][j]`` where ``0 <= j < 3`` is ``(N, I)`` shape as they
          are multiplied with input variables. All other matrices has
          ``(N, N)`` shape.
      bs (list of list of :class:`~chainerx.array`): Bias vectors.
          ``bs[i]`` represnents biases for i-th layer.
          Each ``bs[i]`` is a list containing six vectors.
          ``bs[i][j]`` is corresponding with ``b_j`` in the equation.
          Shape of each matrix is ``(N,)`` where ``N`` is dimension of
          hidden units.
      xs (list of :class:`~chainerx.array`):
          A list of :class:`~chainerx.array`
          holding input values. Each element ``xs[t]`` holds input value
          for time ``t``. Its shape is ``(B_t, I)``, where ``B_t`` is
          mini-batch size for time ``t``, and ``I`` is size of input units.
          Note that this function supports variable length sequences.
          When sequneces has different lengths, sort sequences in descending
          order by length.
          So ``xs`` needs to satisfy
          ``xs[t].shape[0] >= xs[t + 1].shape[0]``.
  
  Returns:
      tuple: This function returns a tuple containing two elements,
      ``hy`` and ``ys``.
  
      - ``hy`` is an updated hidden states whose shape is same as ``hx``.
      - ``ys`` is a list of :class:`~chainerx.array` . Each element
        ``ys[t]`` holds hidden states of the last layer corresponding
        to an input ``xs[t]``. Its shape is ``(B_t, N)`` where ``B_t`` is
        mini-batch size for time ``t``, and ``N`` is size of hidden
        units. Note that ``B_t`` is the same value as ``xs[t]``
      """,
      )
  
      _docs.set_doc(
          chainerx.n_step_bigru,
          """n_step_bigru(n_layers, hx, ws, bs, xs)
  Stacked Bi-directional Gated Recurrent Unit function.
  This function calculates stacked Bi-directional GRU with sequences.
  This function gets an initial hidden state :math:`h_0`, an input
  sequence :math:`x`, weight matrices :math:`W`, and bias vectors :math:`b`.
  This function calculates hidden states :math:`h_t` for each time :math:`t`
  from input :math:`x_t`.
  
  .. math::
     r^{f}_t &= \\sigma(W^{f}_0 x_t + W^{f}_3 h_{t-1} + b^{f}_0 + b^{f}_3)
     \\\\
     z^{f}_t &= \\sigma(W^{f}_1 x_t + W^{f}_4 h_{t-1} + b^{f}_1 + b^{f}_4)
     \\\\
     h^{f'}_t &= \\tanh(W^{f}_2 x_t + b^{f}_2 + r^{f}_t \\cdot (W^{f}_5
     h_{t-1} + b^{f}_5)) \\\\
     h^{f}_t &= (1 - z^{f}_t) \\cdot h^{f'}_t + z^{f}_t \\cdot h_{t-1}
     \\\\
     r^{b}_t &= \\sigma(W^{b}_0 x_t + W^{b}_3 h_{t-1} + b^{b}_0 + b^{b}_3)
     \\\\
     z^{b}_t &= \\sigma(W^{b}_1 x_t + W^{b}_4 h_{t-1} + b^{b}_1 + b^{b}_4)
     \\\\
     h^{b'}_t &= \\tanh(W^{b}_2 x_t + b^{b}_2 + r^{b}_t \\cdot (W^{b}_5
     h_{t-1} + b^{b}_5)) \\\\
     h^{b}_t &= (1 - z^{b}_t) \\cdot h^{b'}_t + z^{b}_t \\cdot h_{t-1}
     \\\\
     h_t  &= [h^{f}_t; h^{b}_t] \\\\
  
  where :math:`W^{f}` is weight matrices for forward-GRU, :math:`W^{b}` is
  weight matrices for backward-GRU.
  As the function accepts a sequence, it calculates :math:`h_t` for all
  :math:`t` with one call. Six weight matrices and six bias vectors are
  required for each layers. So, when :math:`S` layers exists, you need to
  prepare :math:`6S` weight matrices and :math:`6S` bias vectors.
  If the number of layers ``n_layers`` is greather than :math:`1`, input
  of ``k``-th layer is hidden state ``h_t`` of ``k-1``-th layer.
  Note that all input variables except first layer may have different shape
  from the first layer.
  
  Args:
      n_layers(int): Number of layers.
      hx (:class:`~chainerx.array`):
          Variable holding stacked hidden states.
          Its shape is ``(2S, B, N)`` where ``S`` is number of layers and is
          equal to ``n_layers``, ``B`` is mini-batch size, and ``N`` is
          dimension of hidden units.
      ws (list of list of :class:`~chainerx.array`): Weight matrices.
          ``ws[i]`` represents weights for i-th layer.
          Each ``ws[i]`` is a list containing six matrices.
          ``ws[i][j]`` is corresponding with ``W_j`` in the equation.
          Only ``ws[0][j]`` where ``0 <= j < 3`` is ``(N, I)`` shape as they
          are multiplied with input variables. All other matrices has
          ``(N, N)`` shape.
      bs (list of list of :class:`~chainerx.array`): Bias vectors.
          ``bs[i]`` represnents biases for i-th layer.
          Each ``bs[i]`` is a list containing six vectors.
          ``bs[i][j]`` is corresponding with ``b_j`` in the equation.
          Shape of each matrix is ``(N,)`` where ``N`` is dimension of
          hidden units.
      xs (list of :class:`~chainerx.array`):
          A list of :class:`~chainerx.array` holding input values.
          Each element ``xs[t]`` holds input value
          for time ``t``. Its shape is ``(B_t, I)``, where ``B_t`` is
          mini-batch size for time ``t``, and ``I`` is size of input units.
          Note that this function supports variable length sequences.
          When sequneces has different lengths, sort sequences in descending
          order by length.
          So ``xs`` needs to satisfy
          ``xs[t].shape[0] >= xs[t + 1].shape[0]``.
  
  Returns:
      tuple: This function returns a tuple containing two elements,
      ``hy`` and ``ys``.
  
      - ``hy`` is an updated hidden states whose shape is same as ``hx``.
      - ``ys`` is a list of :class:`~chainerx.array` . Each element
        ``ys[t]`` holds hidden states of the last layer corresponding
        to an input ``xs[t]``. Its shape is ``(B_t, N)`` where ``B_t`` is
        mini-batch size for time ``t``, and ``N`` is size of hidden
        units. Note that ``B_t`` is the same value as ``xs[t]``.
      """,
      )
  
      _docs.set_doc(
          chainerx.n_step_rnn,
          """n_step_rnn(n_layers, hx, ws, bs, xs, activation='tanh')
  Stacked Uni-directional RNN function for sequence inputs.
  This function calculates stacked Uni-directional RNN with sequences.
  This function gets an initial hidden state :math:`h_0`,
  an initial cell state :math:`c_0`, an input sequence :math:`x`,
  weight matrices :math:`W`, and bias vectors :math:`b`.
  This function calculates hidden states :math:`h_t` and :math:`c_t` for each
  time :math:`t` from input :math:`x_t`.
  
  .. math::
     h_t = f(W_0 x_t + W_1 h_{t-1} + b_0 + b_1)
  
  where :math:`f` is an activation function.
  Weight matrices :math:`W` contains two matrices :math:`W_0` and
  :math:`W_1`. :math:`W_0` is a parameter for an input sequence.
  :math:`W_1` is a parameter for a hidden state.
  Bias matrices :math:`b` contains two matrices :math:`b_0` and :math:`b_1`.
  :math:`b_0` is a parameter for an input sequence.
  :math:`b_1` is a parameter for a hidden state.
  As the function accepts a sequence, it calculates :math:`h_t` for all
  :math:`t` with one call. Two weight matrices and two bias vectors are
  required for each layer. So, when :math:`S` layers exist, you need to
  prepare :math:`2S` weight matrices and :math:`2S` bias vectors.
  If the number of layers ``n_layers`` is greather than :math:`1`, input
  of ``k``-th layer is hidden state ``h_t`` of ``k-1``-th layer.
  Note that all input variables except first layer may have different shape
  from the first layer.
  
  Args:
      n_layers(int): Number of layers.
      hx (:class:`~chainerx.array`):
          Variable holding stacked hidden states.
          Its shape is ``(S, B, N)`` where ``S`` is number of layers and is
          equal to ``n_layers``, ``B`` is mini-batch size, and ``N`` is
          dimension of hidden units.
      ws (list of list of :class:`~chainerx.array`): Weight matrices.
          ``ws[i]`` represents weights for i-th layer.
          Each ``ws[i]`` is a list containing two matrices.
          ``ws[i][j]`` is corresponding with ``W_j`` in the equation.
          Only ``ws[0][j]`` where ``0 <= j < 1`` is ``(N, I)`` shape as they
          are multiplied with input variables. All other matrices has
          ``(N, N)`` shape.
      bs (list of list of :class:`~chainerx.array`): Bias vectors.
          ``bs[i]`` represnents biases for i-th layer.
          Each ``bs[i]`` is a list containing two vectors.
          ``bs[i][j]`` is corresponding with ``b_j`` in the equation.
          Shape of each matrix is ``(N,)`` where ``N`` is dimension of
          hidden units.
      xs (list of :class:`~chainerx.array`):
          A list of :class:`~chainerx.array` holding input values.
          Each element ``xs[t]`` holds input value for time ``t``.
          Its shape is ``(B_t, I)``, where ``B_t`` is
          mini-batch size for time ``t``, and ``I`` is size of input units.
          Note that this function supports variable length sequences.
          When sequneces has different lengths, sort sequences in descending
          order by length.
          So ``xs`` needs to satisfy
          ``xs[t].shape[0] >= xs[t + 1].shape[0]``.
      activation (str): Activation function name.
          Please select ``tanh`` or ``relu``.
  
  Returns:
      tuple: This function returns a tuple containing two elements,
      ``hy`` and ``ys``.
  
      - ``hy`` is an updated hidden states whose shape is same as ``hx``.
      - ``ys`` is a list of :class:`~chainerx.array` . Each element
        ``ys[t]`` holds hidden states of the last layer corresponding
        to an input ``xs[t]``. Its shape is ``(B_t, N)`` where ``B_t`` is
        mini-batch size for time ``t``, and ``N`` is size of hidden
        units. Note that ``B_t`` is the same value as ``xs[t]``.
      """,
      )
  
      _docs.set_doc(
          chainerx.n_step_birnn,
          """n_step_birnn(n_layers, hx, ws, bs, xs, activation='tanh')
  Stacked Bi-directional RNN function for sequence inputs.
  This function calculates stacked Bi-directional RNN with sequences.
  This function gets an initial hidden state :math:`h_0`, an initial
  cell state :math:`c_0`, an input sequence :math:`x`,
  weight matrices :math:`W`, and bias vectors :math:`b`.
  This function calculates hidden states :math:`h_t` and :math:`c_t` for each
  time :math:`t` from input :math:`x_t`.
  
  .. math::
      h^{f}_t &=& f(W^{f}_0 x_t + W^{f}_1 h_{t-1} + b^{f}_0 + b^{f}_1), \\\\
      h^{b}_t &=& f(W^{b}_0 x_t + W^{b}_1 h_{t-1} + b^{b}_0 + b^{b}_1), \\\\
      h_t  &=& [h^{f}_t; h^{f}_t], \\\\
  
  where :math:`f` is an activation function.
  Weight matrices :math:`W` contains two matrices :math:`W^{f}` and
  :math:`W^{b}`. :math:`W^{f}` is weight matrices for forward directional
  RNN. :math:`W^{b}` is weight matrices for backward directional RNN.
  :math:`W^{f}` contains :math:`W^{f}_0` for an input sequence and
  :math:`W^{f}_1` for a hidden state.
  :math:`W^{b}` contains :math:`W^{b}_0` for an input sequence and
  :math:`W^{b}_1` for a hidden state.
  Bias matrices :math:`b` contains two matrices :math:`b^{f}` and
  :math:`b^{f}`. :math:`b^{f}` contains :math:`b^{f}_0` for an input sequence
  and :math:`b^{f}_1` for a hidden state.
  :math:`b^{b}` contains :math:`b^{b}_0` for an input sequence and
  :math:`b^{b}_1` for a hidden state.
  As the function accepts a sequence, it calculates :math:`h_t` for all
  :math:`t` with one call. Two weight matrices and two bias vectors are
  required for each layer. So, when :math:`S` layers exist, you need to
  prepare :math:`2S` weight matrices and :math:`2S` bias vectors.
  If the number of layers ``n_layers`` is greather than :math:`1`, input
  of ``k``-th layer is hidden state ``h_t`` of ``k-1``-th layer.
  Note that all input variables except first layer may have different shape
  from the first layer.
  
  Args:
      n_layers(int): Number of layers.
      hx (:class:`~chainerx.array`):
          Variable holding stacked hidden states.
          Its shape is ``(2S, B, N)`` where ``S`` is number of layers and is
          equal to ``n_layers``, ``B`` is mini-batch size, and ``N`` is
          dimension of hidden units. Because of bi-direction, the
          first dimension length is ``2S``.
      ws (list of list of :class:`~chainerx.array`): Weight matrices.
          ``ws[i + di]`` represents weights for i-th layer.
          Note that ``di = 0`` for forward-RNN and ``di = 1`` for
          backward-RNN.
          Each ``ws[i + di]`` is a list containing two matrices.
          ``ws[i + di][j]`` is corresponding with ``W^{f}_j`` if ``di = 0``
          and corresponding with ``W^{b}_j`` if ``di = 1`` in the equation.
          Only ``ws[0][j]`` and ``ws[1][j]`` where ``0 <= j < 1`` are
          ``(I, N)`` shape as they are multiplied with input variables.
          All other matrices has ``(N, N)`` shape.
      bs (list of list of :class:`~chainerx.array`): Bias vectors.
          ``bs[i + di]`` represnents biases for i-th layer.
          Note that ``di = 0`` for forward-RNN and ``di = 1`` for
          backward-RNN.
          Each ``bs[i + di]`` is a list containing two vectors.
          ``bs[i + di][j]`` is corresponding with ``b^{f}_j`` if ``di = 0``
          and corresponding with ``b^{b}_j`` if ``di = 1`` in the equation.
          Shape of each matrix is ``(N,)`` where ``N`` is dimension of
          hidden units.
      xs (list of :class:`~chainerx.array`):
          A list of :class:`~chainerx.array` holding input values.
          Each element ``xs[t]`` holds input value
          for time ``t``. Its shape is ``(B_t, I)``, where ``B_t`` is
          mini-batch size for time ``t``, and ``I`` is size of input units.
          Note that this function supports variable length sequences.
          When sequneces has different lengths, sort sequences in descending
          order by length.
          So ``xs`` needs to satisfy
          ``xs[t].shape[0] >= xs[t + 1].shape[0]``.
      activation (str): Activation function name.
          Please select ``tanh`` or ``relu``.
  
  Returns:
      tuple: This function returns a tuple containing two elements,
      ``hy`` and ``ys``.
  
      - ``hy`` is an updated hidden states whose shape is same as ``hx``.
      - ``ys`` is a list of :class:`~chainerx.array` . Each element
        ``ys[t]`` holds hidden states of the last layer corresponding
        to an input ``xs[t]``. Its shape is ``(B_t, N)`` where ``B_t``
        is mini-batch size for time ``t``, and ``N`` is size of hidden
        units. Note that ``B_t`` is the same value as ``xs[t]``.
      """,
      )
  
file_path: chainer/chainerx/_docs/routines.py
imports: import chainerx
  from chainerx import _docs
label_desc: Use image node_id 15 for calling a global function with example usage: _docs_rnn() without return types