code: def testAreaMean(self):
      batch_size = 256
      feature_len = 100
      memory_height = 10
      heads = 2
      key_len = 2
      depth = 128
      max_area_height = 3
      max_area_width = 3
      queries = tf.random_uniform(
          [batch_size, heads, key_len, depth], minval=-10.0, maxval=10.0
      )
      features = tf.random_uniform(
          [batch_size, heads, feature_len, depth],
          minval=-10.0,
          maxval=10.0,
      )
      target_values = tf.random_uniform(
          [batch_size, heads, key_len, depth], minval=-0.2, maxval=0.2
      )
      keys = tf.layers.dense(features, units=depth)
      values = tf.layers.dense(features, units=depth)
      mean_attention = area_attention.dot_product_area_attention(
          queries,
          keys,
          values,
          bias=None,
          area_key_mode="mean",
          name="mean_key",
          max_area_width=max_area_width,
          max_area_height=max_area_height,
          memory_height=memory_height,
      )
      mean_gradients = tf.gradients(
          tf.reduce_mean(tf.pow(target_values - mean_attention, 2)),
          features,
      )
      with self.test_session() as session:
          session.run(tf.global_variables_initializer())
          result = session.run([mean_gradients])
      self.assertFalse(np.any(np.logical_not(np.isfinite(result))))
  
file_path: tensor2tensor/tensor2tensor/layers/area_attention_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import numpy
  from tensor2tensor.layers import area_attention
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling the AreaAttentionTest obj's underlying member method code with example usage: obj.testAreaMean() without return types