code: def crop_image_sampling(
      img, sample_bbox, image_width, image_height, target_size
  ):
      # no clipping here
      xmin = int(sample_bbox[0] * image_width)
      xmax = int(sample_bbox[2] * image_width)
      ymin = int(sample_bbox[1] * image_height)
      ymax = int(sample_bbox[3] * image_height)
  
      w_off = xmin
      h_off = ymin
      width = xmax - xmin
      height = ymax - ymin
      cross_xmin = max(0.0, float(w_off))
      cross_ymin = max(0.0, float(h_off))
      cross_xmax = min(float(w_off + width - 1.0), float(image_width))
      cross_ymax = min(float(h_off + height - 1.0), float(image_height))
      cross_width = cross_xmax - cross_xmin
      cross_height = cross_ymax - cross_ymin
  
      roi_xmin = 0 if w_off >= 0 else abs(w_off)
      roi_ymin = 0 if h_off >= 0 else abs(h_off)
      roi_width = cross_width
      roi_height = cross_height
  
      roi_y1 = int(roi_ymin)
      roi_y2 = int(roi_ymin + roi_height)
      roi_x1 = int(roi_xmin)
      roi_x2 = int(roi_xmin + roi_width)
  
      cross_y1 = int(cross_ymin)
      cross_y2 = int(cross_ymin + cross_height)
      cross_x1 = int(cross_xmin)
      cross_x2 = int(cross_xmin + cross_width)
  
      sample_img = np.zeros((height, width, 3))
      sample_img[roi_y1:roi_y2, roi_x1:roi_x2] = img[
          cross_y1:cross_y2, cross_x1:cross_x2
      ]
  
      sample_img = cv2.resize(
          sample_img,
          (target_size, target_size),
          interpolation=cv2.INTER_AREA,
      )
  
      return sample_img
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import random
  import math
  import cv2
label_desc: Use image node_id 15 for calling a global function with example usage: crop_image_sampling(img, sample_bbox, image_width, image_height, target_size) and returns: sample_img