code: def test_global_average_pooling2d(self, data_format, keepdims):
      def np_gap2d(x, data_format, keepdims):
          steps_axis = (
              [1, 2] if data_format == "channels_last" else [2, 3]
          )
          res = np.apply_over_axes(np.mean, x, steps_axis)
          if not keepdims:
              res = res.squeeze()
          return res
  
      inputs = np.arange(96, dtype="float32").reshape((2, 3, 4, 4))
      layer = layers.GlobalAveragePooling2D(
          data_format=data_format,
          keepdims=keepdims,
      )
      outputs = layer(inputs)
      expected = np_gap2d(inputs, data_format, keepdims)
      self.assertAllClose(outputs, expected)
  
file_path: keras/keras/layers/pooling/global_average_pooling_test.py
imports: import numpy
  import pytest
  from absl.testing import parameterized
  from keras import layers
  from keras import testing
label_desc: Use image node_id 2 for calling the GlobalAveragePoolingCorrectnessTest obj's underlying member method code with example usage: obj.test_global_average_pooling2d(data_format, keepdims) and returns: res