docstr: Test pushing a popping from a NeuralStackCell.
  
  The sequence of operations is:
    push([1.0, 0.0, 0.0])
    push([0.0, 1.0, 0.0])
    pop()
docstr_tok: ["Test","pushing","a","popping","from","a","NeuralStackCell",".","The","sequence","of","operations","is",":","push","(","[","1.0",",","0.0",",","0.0","]",")","push","(","[","0.0",",","1.0",",","0.0","]",")","pop","(",")"]
code: def test_push_pop(self):
      """Test pushing a popping from a NeuralStackCell.
  
      The sequence of operations is:
        push([1.0, 0.0, 0.0])
        push([0.0, 1.0, 0.0])
        pop()
      """
      input_values = np.array(
          [[[[1.0, 0.0, 0.0]], [[0.0, 1.0, 0.0]], [[0.0, 0.0, 1.0]]]]
      )
  
      expected_values = np.array(
          [
              [
                  [1.0, 0.0, 0.0],
                  [0.0, 1.0, 0.0],
                  [0.0, 0.0, 1.0],
                  [0.0, 0.0, 0.0],
                  [0.0, 0.0, 0.0],
                  [0.0, 0.0, 0.0],
              ]
          ]
      )
      expected_read_strengths = np.array(
          [[[[1.0], [0.0], [0.0], [0.0], [0.0], [0.0]]]]
      )
      expected_write_strengths = np.array(
          [[[[0.0], [0.0], [0.0], [1.0], [0.0], [0.0]]]]
      )
      expected_top = np.array([[[1.0, 0.0, 0.0]]])
  
      batch_size = 1
      embedding_size = 3
      memory_size = 6
      num_units = 8
  
      stack = neural_stack.NeuralStackCell(
          num_units, memory_size, embedding_size
      )
      stack_input = tf.constant(input_values, dtype=tf.float32)
  
      stack_zero_state = tf.zeros([batch_size, num_units])
      controller_outputs = stack.call_controller(
          None, None, stack_zero_state, batch_size
      )
      assert_controller_shapes(
          self,
          controller_outputs,
          stack.get_controller_shape(batch_size),
      )
  
      (outputs, state) = tf.nn.dynamic_rnn(
          cell=stack,
          inputs=stack_input,
          time_major=False,
          dtype=tf.float32,
      )
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          _, state_vals = sess.run([outputs, state])
          (
              _,
              stack_top,
              values,
              read_strengths,
              write_strengths,
          ) = state_vals
  
          self.assertAllClose(expected_values, values)
          self.assertAllClose(expected_write_strengths, write_strengths)
          self.assertAllClose(expected_read_strengths, read_strengths)
          self.assertAllClose(expected_top, stack_top)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import mock
  import numpy
  from tensor2tensor.layers import modalities
  from tensor2tensor.models.research import neural_stack
  from tensor2tensor.utils import contrib
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling the NeuralStackCellTest obj's underlying member method code with example usage: obj.test_push_pop() without return types