def call_fake_controller(push_values, pop_values, write_values, output_values):
  """Mock a RNN controller from a set of expected outputs.

  Args:
    push_values: Expected controller push values.
    pop_values: Expected controller pop values.
    write_values: Expected controller write values.
    output_values: Expected controller output values.

  Returns:
    A callable which behaves like the call method of an NeuralStackCell.
  """
  def call(cell, inputs, prev_read_values, controller_state, batch_size):
    del inputs
    del prev_read_values
    del batch_size
    next_step = tf.constant(0)
    if hasattr(cell, "current_step"):
      next_step = tf.assign_add(cell.current_step, tf.constant(1))
    return neural_stack.NeuralStackControllerInterface(
        push_strengths=tf.slice(tf.constant(push_values),
                                [next_step, 0, 0, 0],
                                [1, -1, -1, -1]),
        pop_strengths=tf.slice(tf.constant(pop_values),
                               [next_step, 0, 0, 0],
                               [1, -1, -1, -1]),
        write_values=tf.slice(tf.constant(write_values),
                              [next_step, 0, 0],
                              [1, -1, -1]),
        outputs=tf.slice(tf.constant(output_values),
                         [next_step, 0, 0],
                         [1, -1, -1]),
        state=controller_state
    )
  return call
Mock a RNN controller from a set of expected outputs.

  Args:
    push_values: Expected controller push values.
    pop_values: Expected controller pop values.
    write_values: Expected controller write values.
    output_values: Expected controller output values.

  Returns:
    A callable which behaves like the call method of an NeuralStackCell.
  
tensor2tensor/models/research/neural_stack_test.py