code: def testComputeAreaFeatures2D(self):
      features = tf.constant(
          [
              [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],
              [
                  [1.1, 2.1],
                  [3.1, 4.1],
                  [5.1, 6.1],
                  [7.1, 8.1],
                  [9.1, 10.1],
                  [11.1, 12.1],
              ],
          ],
          dtype=tf.float32,
      )
      (
          area_mean,
          area_std,
          area_sum,
          area_height,
          area_widths,
      ) = area_attention.compute_area_features(
          features,
          max_area_width=3,
          max_area_height=2,
          height=2,
          epsilon=0.0,
      )
      with self.test_session() as session:
          session.run(tf.global_variables_initializer())
          res1, _, res3, res4, res5 = session.run(
              [area_mean, area_std, area_sum, area_height, area_widths]
          )
      expected_means = [
          [
              [1, 2],
              [3, 4],
              [5, 6],
              [7, 8],
              [9, 10],
              [11, 12],
              [2, 3],
              [4, 5],
              [8, 9],
              [10, 11],
              [3, 4],
              [9, 10],
              [4, 5],
              [6, 7],
              [8, 9],
              [5, 6],
              [7, 8],
              [6, 7],
          ],
          [
              [1.1, 2.1],
              [3.1, 4.1],
              [5.1, 6.1],
              [7.1, 8.1],
              [9.1, 10.1],
              [11.1, 12.1],
              [2.1, 3.1],
              [4.1, 5.1],
              [8.1, 9.1],
              [10.1, 11.1],
              [3.1, 4.1],
              [9.1, 10.1],
              [4.1, 5.1],
              [6.1, 7.1],
              [8.1, 9.1],
              [5.1, 6.1],
              [7.1, 8.1],
              [6.1, 7.1],
          ],
      ]
      self.assertAllClose(expected_means, res1, msg="mean_1d")
      expected_heights = [
          [
              [1],
              [1],
              [1],
              [1],
              [1],
              [1],
              # 1x2
              [1],
              [1],
              [1],
              [1],
              # 1x3
              [1],
              [1],
              # 2x1
              [2],
              [2],
              [2],
              # 2x2
              [2],
              [2],
              # 2x3
              [2],
          ],
          [
              [1],
              [1],
              [1],
              [1],
              [1],
              [1],
              # 1x2
              [1],
              [1],
              [1],
              [1],
              # 1x3
              [1],
              [1],
              # 2x1
              [2],
              [2],
              [2],
              # 2x2
              [2],
              [2],
              # 2x3
              [2],
          ],
      ]
      self.assertAllEqual(expected_heights, res4, msg="height_1d")
      expected_widths = [
          [
              [1],
              [1],
              [1],
              [1],
              [1],
              [1],
              # 1x2
              [2],
              [2],
              [2],
              [2],
              # 1x3
              [3],
              [3],
              # 2x1
              [1],
              [1],
              [1],
              # 2x2
              [2],
              [2],
              # 2x3
              [3],
          ],
          [
              [1],
              [1],
              [1],
              [1],
              [1],
              [1],
              # 1x2
              [2],
              [2],
              [2],
              [2],
              # 1x3
              [3],
              [3],
              # 2x1
              [1],
              [1],
              [1],
              # 2x2
              [2],
              [2],
              # 2x3
              [3],
          ],
      ]
      self.assertAllEqual(expected_widths, res5, msg="width_1d")
      sizes = np.multiply(
          np.array(expected_heights), np.array(expected_widths)
      )
      expected_sums = np.multiply(np.array(expected_means), sizes)
      self.assertAllClose(expected_sums, res3, msg="sum_1d")
  
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 2 for calling the AreaAttentionTest obj's underlying member method code with example usage: obj.testComputeAreaFeatures2D() without return types