code: def testAttentionCellWrapperZeros(self):
      num_units = 8
      attn_length = 16
      batch_size = 3
      input_size = 4
      for state_is_tuple in [False, True]:
          with tf.Graph().as_default():
              with self.cached_session() as sess:
                  with tf.variable_scope(
                      "state_is_tuple_" + str(state_is_tuple)
                  ):
                      lstm_cell = rnn_cell.BasicLSTMCell(
                          num_units, state_is_tuple=state_is_tuple
                      )
                      cell = contrib_rnn.AttentionCellWrapper(
                          lstm_cell,
                          attn_length,
                          state_is_tuple=state_is_tuple,
                      )
                      if state_is_tuple:
                          zeros = tf.zeros(
                              [batch_size, num_units], dtype=np.float32
                          )
                          attn_state_zeros = tf.zeros(
                              [batch_size, attn_length * num_units],
                              dtype=np.float32,
                          )
                          zero_state = (
                              (zeros, zeros),
                              zeros,
                              attn_state_zeros,
                          )
                      else:
                          zero_state = tf.zeros(
                              [
                                  batch_size,
                                  num_units * 2
                                  + attn_length * num_units
                                  + num_units,
                              ],
                              dtype=np.float32,
                          )
                      inputs = tf.zeros(
                          [batch_size, input_size], dtype=tf.float32
                      )
                      output, state = cell(inputs, zero_state)
                      self.assertEqual(
                          output.get_shape(), [batch_size, num_units]
                      )
                      if state_is_tuple:
                          self.assertEqual(len(state), 3)
                          self.assertEqual(len(state[0]), 2)
                          self.assertEqual(
                              state[0][0].get_shape(),
                              [batch_size, num_units],
                          )
                          self.assertEqual(
                              state[0][1].get_shape(),
                              [batch_size, num_units],
                          )
                          self.assertEqual(
                              state[1].get_shape(),
                              [batch_size, num_units],
                          )
                          self.assertEqual(
                              state[2].get_shape(),
                              [batch_size, attn_length * num_units],
                          )
                          tensors = [output] + list(state)
                      else:
                          self.assertEqual(
                              state.get_shape(),
                              [
                                  batch_size,
                                  num_units * 2
                                  + num_units
                                  + attn_length * num_units,
                              ],
                          )
                          tensors = [output, state]
                      zero_result = sum(
                          [tf.reduce_sum(tf.abs(x)) for x in tensors]
                      )
                      sess.run(tf.global_variables_initializer())
                      self.assertLess(sess.run(zero_result), 1e-6)
  
imports: import itertools
  from absl.testing import parameterized
  from magenta.contrib import rnn
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling the RNNCellTest obj's underlying member method code with example usage: obj.testAttentionCellWrapperZeros() without return types