keras/src/layers/pooling/base_global_pooling.py/BaseGlobalPooling/compute_output_shape
class BaseGlobalPooling:    def compute_output_shape(self, input_shape):
        num_spatial_dims = len(input_shape) - 2
        if self.data_format == "channels_last":
            if self.keepdims:
                return (
                    (input_shape[0],)
                    + (1,) * num_spatial_dims
                    + (input_shape[-1],)
                )
            else:
                return (input_shape[0],) + (input_shape[-1],)
        else:
            if self.keepdims:
                return (input_shape[0], input_shape[1]) + (
                    1,
                ) * num_spatial_dims
            else:
                return (input_shape[0], input_shape[1])