def call_controller(self, input_value, read_values, prev_state, batch_size):
    """Make a call to the neural stack controller.

    See Section 3.1 of Grefenstette et al., 2015.

    Args:
      input_value: The input to the neural stack cell should be a tf.float32
        tensor with shape [batch_size, 1, embedding_size]
      read_values: The values of the read heads at the previous timestep.
      prev_state: The hidden state from the previous time step.
      batch_size: The size of the current batch of input values.

    Returns:
      A tuple of outputs and the new NeuralStackControllerInterface.
    """
    with tf.name_scope("controller"):
      # Concatenate the current input value with the read values from the
      # previous timestep before feeding them into the controller.
      controller_inputs = tf.concat([
          contrib.layers().flatten(input_value),
          contrib.layers().flatten(read_values),
      ],
                                    axis=1)

      rnn_input = tf.tanh(tf.nn.bias_add(tf.matmul(
          controller_inputs, self._input_proj), self._input_bias))

      (rnn_output, state) = self.rnn(rnn_input, prev_state)

      push_strengths = tf.sigmoid(tf.nn.bias_add(tf.matmul(
          rnn_output, self._push_proj), self._push_bias))

      pop_strengths = tf.sigmoid(tf.nn.bias_add(tf.matmul(
          rnn_output, self._pop_proj), self._pop_bias))

      write_values = tf.tanh(tf.nn.bias_add(tf.matmul(
          rnn_output, self._value_proj), self._value_bias))

      outputs = tf.tanh(tf.nn.bias_add(tf.matmul(
          rnn_output, self._output_proj), self._output_bias))

      # Reshape all the outputs according to the shapes specified by
      # get_controller_shape()
      projected_outputs = [push_strengths,
                           pop_strengths,
                           write_values,
                           outputs,
                           state]
      next_state = [
          tf.reshape(output, shape=output_shape) for output, output_shape
          in zip(projected_outputs, self.get_controller_shape(batch_size))]
      return NeuralStackControllerInterface(*next_state)
Make a call to the neural stack controller.

    See Section 3.1 of Grefenstette et al., 2015.

    Args:
      input_value: The input to the neural stack cell should be a tf.float32
        tensor with shape [batch_size, 1, embedding_size]
      read_values: The values of the read heads at the previous timestep.
      prev_state: The hidden state from the previous time step.
      batch_size: The size of the current batch of input values.

    Returns:
      A tuple of outputs and the new NeuralStackControllerInterface.
    
tensor2tensor/models/research/neural_stack.py