code: def crop_augmenter(
      image,
      annotation,
      random,
      skip_probability=_DEFAULT_AUG_PARAMS["skip_probability_crop"],
      min_aspect_ratio=_DEFAULT_AUG_PARAMS["min_aspect_ratio"],
      max_aspect_ratio=_DEFAULT_AUG_PARAMS["max_aspect_ratio"],
      min_area_fraction=_DEFAULT_AUG_PARAMS["min_area_fraction_crop"],
      max_area_fraction=_DEFAULT_AUG_PARAMS["max_area_fraction_crop"],
      min_object_covered=_DEFAULT_AUG_PARAMS["min_object_covered"],
      max_attempts=_DEFAULT_AUG_PARAMS["max_attempts"],
      min_eject_coverage=_DEFAULT_AUG_PARAMS["min_eject_coverage"],
  ):
      if random.uniform(0.0, 1.0) < skip_probability:
          return np.array(image), annotation
  
      image_height, image_width, _ = image.shape
  
      # Sample crop rects until one satisfies our constraints (by yielding a valid
      # list of cropped annotations), or reaching the limit on attempts.
      for i in range(max_attempts):
          # Randomly sample an aspect ratio.
          aspect_ratio = random.uniform(
              min_aspect_ratio, max_aspect_ratio
          )
  
          # Next we'll sample a height (which combined with the now known aspect
          # ratio, determines the size and area). But first we must compute the range
          # of valid heights. The crop cannot be taller than the original image,
          # cannot be wider than the original image, and must have an area in the
          # specified range.
  
          # The cropped height must be no larger the original height.
          # h' <= h
          max_height = float(image_height)
  
          # The cropped width must be no larger than the original width.
          # w' <= w IMPLIES ah' <= w IMPLIES h' <= w / a
          max_height_from_width = float(image_width) / aspect_ratio
          if max_height > max_height_from_width:
              max_height = max_height_from_width
  
          # The cropped area must not exceed the maximum area fraction.
          max_height_from_area = np.sqrt(
              image_height
              * image_width
              * max_area_fraction
              / aspect_ratio
          )
          if max_height > max_height_from_area:
              max_height = max_height_from_area
  
          # The padded area must attain the minimum area fraction.
          min_height = np.sqrt(
              image_height
              * image_width
              * min_area_fraction
              / aspect_ratio
          )
  
          # If the range is empty, then crops with the sampled aspect ratio cannot
          # satisfy the area constraint.
          if min_height > max_height:
              continue
  
          # Sample a position for the crop, constrained to lie within the image.
          cropped_height = random.uniform(min_height, max_height)
          cropped_width = cropped_height * aspect_ratio
  
          x_offset = random.uniform(0.0, (image_width - cropped_width))
          y_offset = random.uniform(
              0.0, (image_height - cropped_height)
          )
  
          crop_bounds_x1 = x_offset
          crop_bounds_y1 = y_offset
          crop_bounds_x2 = x_offset + cropped_width
          crop_bounds_y2 = y_offset + cropped_height
  
          formatted_annotation = []
          is_min_object_covered = True
          for aug in annotation:
              identifier = aug[0:1]
              bounds = aug[1:5]
              confidence = aug[5:6]
  
              width = bounds[2]
              height = bounds[3]
  
              x1 = bounds[0] * image_width
              y1 = bounds[1] * image_height
  
              x2 = (bounds[0] + width) * image_width
              y2 = (bounds[1] + height) * image_height
  
              # This tests whether the crop bounds are out of the annotated bounds, if not it returns an empty annotation
              if (
                  crop_bounds_x1 < x2
                  and crop_bounds_y1 < y2
                  and x1 < crop_bounds_x2
                  and y1 < crop_bounds_y2
              ):
                  x_bounds = [
                      x1,
                      x2,
                      x_offset,
                      x_offset + cropped_width,
                  ]
                  y_bounds = [
                      y1,
                      y2,
                      y_offset,
                      y_offset + cropped_height,
                  ]
  
                  x_bounds.sort()
                  y_bounds.sort()
  
                  x_pairs = x_bounds[1:3]
                  y_pairs = y_bounds[1:3]
  
                  intersection = np.array(
                      [y_pairs[0], x_pairs[0], y_pairs[1], x_pairs[1]]
                  )
  
                  intersection_area = (
                      intersection[3] - intersection[1]
                  ) * (intersection[2] - intersection[0])
                  annotation_area = (y2 - y1) * (x2 - x1)
  
                  area_coverage = intersection_area / annotation_area
  
                  # Invalidate the crop if it did not sufficiently overlap each annotation and try again.
                  if area_coverage < min_object_covered:
                      is_min_object_covered = False
                      break
  
                  # If the area coverage is greater the min_eject_coverage, then actually keep the annotation
                  if area_coverage >= min_eject_coverage:
                      # Transformation matrix for the annotations
                      transformation_matrix = np.array(
                          [
                              [1.0, 0.0, -y_offset],
                              [0.0, 1.0, -x_offset],
                              [0.0, 0.0, 1.0],
                          ]
                      )
  
                      v = np.concatenate(
                          [
                              intersection.reshape((2, 2)),
                              np.ones((2, 1), dtype=np.float32),
                          ],
                          axis=1,
                      )
                      transposed_v = np.dot(
                          v, np.transpose(transformation_matrix)
                      )
                      t_intersection = np.squeeze(
                          transposed_v[:, :2].reshape(-1, 4)
                      )
  
                      # Sort the points top, left, bottom, right
                      if t_intersection[0] > t_intersection[2]:
                          t_intersection[0], t_intersection[2] = (
                              t_intersection[2],
                              t_intersection[0],
                          )
                      if t_intersection[1] > t_intersection[3]:
                          t_intersection[1], t_intersection[3] = (
                              t_intersection[3],
                              t_intersection[1],
                          )
  
                      # Normalize the elements to the cropped width and height
                      ele_1 = t_intersection[1] / cropped_width
                      ele_2 = t_intersection[0] / cropped_height
                      ele_3 = (
                          t_intersection[3] - t_intersection[1]
                      ) / cropped_width
                      ele_4 = (
                          t_intersection[2] - t_intersection[0]
                      ) / cropped_height
  
                      formatted_annotation.append(
                          np.concatenate(
                              [
                                  identifier,
                                  np.array(
                                      [ele_1, ele_2, ele_3, ele_4]
                                  ),
                                  confidence,
                              ]
                          )
                      )
                  else:
                      formatted_annotation.append(
                          np.concatenate(
                              [
                                  identifier,
                                  np.array([0.0, 0.0, 0.0, 0.0]),
                                  confidence,
                              ]
                          )
                      )
              else:
                  formatted_annotation.append(
                      np.concatenate(
                          [
                              identifier,
                              np.array([0.0, 0.0, 0.0, 0.0]),
                              confidence,
                          ]
                      )
                  )
  
          if not is_min_object_covered:
              continue
  
          y_offset = int(y_offset)
          x_offset = int(x_offset)
          end_y = int(cropped_height + y_offset)
          end_x = int(cropped_width + x_offset)
  
          image_cropped = image[y_offset:end_y, x_offset:end_x]
  
          return np.array(image_cropped), np.array(
              formatted_annotation, dtype=np.float32
          )
  
      return np.array(image), annotation
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import numpy
  from PIL import Image
  import turicreate.toolkits._tf_utils
  import turicreate
  from turicreate._deps.minimal_package import _minimal_package_import_check
label_desc: Use image node_id 8 for calling a global function with example usage: crop_augmenter(image, annotation, random, skip_probability, min_aspect_ratio, max_aspect_ratio, min_area_fraction, max_area_fraction, min_object_covered, max_attempts, min_eject_coverage) and returns: np,  annotation, np,  annotation, np,  np