code: def np_center_crop(
      self, img, h_new, w_new, data_format="channels_last"
  ):
      img = np.array(img)
      if img.ndim == 4:
          if data_format == "channels_last":
              _, h, w = img.shape[:3]
          else:
              _, h, w = img.shape[1:]
      else:
          if data_format == "channels_last":
              h, w = img.shape[:2]
          else:
              h, w = img.shape[1:]
      h_start = (h - h_new) // 2
      w_start = (w - w_new) // 2
      if data_format == "channels_last":
          return img[
              ...,
              h_start : h_start + h_new,
              w_start : w_start + w_new,
              :,
          ]
      else:
          return img[
              ..., h_start : h_start + h_new, w_start : w_start + w_new
          ]
  
file_path: keras/keras/layers/preprocessing/center_crop_test.py
imports: import numpy
  import pytest
  from absl.testing import parameterized
  from tensorflow import data
  from keras import backend
  from keras import layers
  from keras import testing
label_desc: Use image node_id 1 for calling the CenterCropTest obj's underlying member method code with example usage: obj.np_center_crop(img, h_new, w_new, data_format) and returns: img, img