code: def test_global_average_pooling1d(self, data_format, keepdims):
      def np_gap1d(x, data_format, keepdims, mask=None):
          steps_axis = 1 if data_format == "channels_last" else 2
          if mask is not None:
              mask = np.expand_dims(
                  mask, 2 if data_format == "channels_last" else 1
              )
              x *= mask
              res = np.sum(x, axis=steps_axis) / np.sum(
                  mask, axis=steps_axis
              )
          else:
              res = np.mean(x, axis=steps_axis)
          if keepdims:
              res = np.expand_dims(res, axis=steps_axis)
          return res
  
      inputs = np.arange(24, dtype="float32").reshape((2, 3, 4))
      layer = layers.GlobalAveragePooling1D(
          data_format=data_format,
          keepdims=keepdims,
      )
      outputs = layer(inputs)
      expected = np_gap1d(inputs, data_format, keepdims)
      self.assertAllClose(outputs, expected)
  
      if data_format == "channels_last":
          mask = np.array([[1, 1, 0], [0, 1, 0]], dtype="int32")
      else:
          mask = np.array([[1, 1, 0, 0], [0, 1, 0, 1]], dtype="int32")
      outputs = layer(inputs, mask)
      expected = np_gap1d(inputs, data_format, keepdims, mask)
      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 1 for calling the GlobalAveragePoolingCorrectnessTest obj's underlying member method code with example usage: obj.test_global_average_pooling1d(data_format, keepdims) and returns: res