code: def clipped_zoom(img, zoom_factor):
    
    h = img.shape[0]
    ch = int(np.ceil(h / float(zoom_factor)))
    top_h = (h - ch) // 2
  
    w = img.shape[1]
    cw = int(np.ceil(w / float(zoom_factor)))
    top_w = (w - cw) // 2
  
    img = tfds.core.lazy_imports.scipy.ndimage.zoom(
        img[top_h:top_h + ch, top_w:top_w + cw], (zoom_factor, zoom_factor, 1),
        order=1)
  
    # trim off any extra pixels
    trim_top_h = (img.shape[0] - h) // 2
    trim_top_w = (img.shape[1] - w) // 2
  
    return img[trim_top_h:trim_top_h + h, trim_top_w:trim_top_w + w]
docs: Zoom image with clipping.
  
    Zoom the central part of the image and clip extra pixels.
  
    Args:
      img: numpy array, uncorrupted image.
      zoom_factor: numpy array, a sequence of float numbers for zoom factor.
  
    Returns:
      numpy array, zoomed image after clipping.