Connects the VanillaRNN module into the graph.

    If this is not the first time the module has been connected to the graph,
    the Tensors provided as input_ and state must have the same final
    dimension, in order for the existing variables to be the correct size for
    their corresponding multiplications. The batch size may differ for each
    connection.

    Args:
      input_: a 2D Tensor of size [batch_size, input_size].
      prev_state: a 2D Tensor of size [batch_size, hidden_size].

    Returns:
      output: a 2D Tensor of size [batch_size, hidden_size].
      next_state: a Tensor of size [batch_size, hidden_size].

    Raises:
      ValueError: if connecting the module into the graph any time after the
        first time, and the inferred size of the inputs does not match previous
        invocations.

def _build(self, input_, prev_state):
    """Connects the VanillaRNN module into the graph.

    If this is not the first time the module has been connected to the graph,
    the Tensors provided as input_ and state must have the same final
    dimension, in order for the existing variables to be the correct size for
    their corresponding multiplications. The batch size may differ for each
    connection.

    Args:
      input_: a 2D Tensor of size [batch_size, input_size].
      prev_state: a 2D Tensor of size [batch_size, hidden_size].

    Returns:
      output: a 2D Tensor of size [batch_size, hidden_size].
      next_state: a Tensor of size [batch_size, hidden_size].

    Raises:
      ValueError: if connecting the module into the graph any time after the
        first time, and the inferred size of the inputs does not match previous
        invocations.
    """
    self._in_to_hidden_linear = basic.Linear(
        self._hidden_size, name="in_to_hidden",
        initializers=self._initializers.get("in_to_hidden"),
        partitioners=self._partitioners.get("in_to_hidden"),
        regularizers=self._regularizers.get("in_to_hidden"))

    self._hidden_to_hidden_linear = basic.Linear(
        self._hidden_size, name="hidden_to_hidden",
        initializers=self._initializers.get("hidden_to_hidden"),
        partitioners=self._partitioners.get("hidden_to_hidden"),
        regularizers=self._regularizers.get("hidden_to_hidden"))

    in_to_hidden = self._in_to_hidden_linear(input_)
    hidden_to_hidden = self._hidden_to_hidden_linear(prev_state)
    output = self._activation(in_to_hidden + hidden_to_hidden)

    # For VanillaRNN, the next state of the RNN is the same as the output
    return output, output