code: def _generate_per_layer_crops(
      crop_n_layers, overlap_ratio, original_size
  ):
      """
      Generates 2 ** (layers idx + 1) crops for each crop_n_layers. Crops are in the XYWH format : The XYWH format
      consists of the following required indices:
          - X: X coordinate of the top left of the bounding box
          - Y: Y coordinate of the top left of the bounding box
          - W: width of the bounding box
          - H: height of the bounding box
      """
      crop_boxes, layer_idxs = [], []
      im_height, im_width = original_size
      short_side = min(im_height, im_width)
  
      # Original image
      crop_boxes.append([0, 0, im_width, im_height])
      layer_idxs.append(0)
      for i_layer in range(crop_n_layers):
          n_crops_per_side = 2 ** (i_layer + 1)
          overlap = int(
              overlap_ratio * short_side * (2 / n_crops_per_side)
          )
  
          crop_width = int(
              math.ceil(
                  (overlap * (n_crops_per_side - 1) + im_width)
                  / n_crops_per_side
              )
          )
          crop_height = int(
              math.ceil(
                  (overlap * (n_crops_per_side - 1) + im_height)
                  / n_crops_per_side
              )
          )
  
          crop_box_x0 = [
              int((crop_width - overlap) * i)
              for i in range(n_crops_per_side)
          ]
          crop_box_y0 = [
              int((crop_height - overlap) * i)
              for i in range(n_crops_per_side)
          ]
  
          for left, top in product(crop_box_x0, crop_box_y0):
              box = [
                  left,
                  top,
                  min(left + crop_width, im_width),
                  min(top + crop_height, im_height),
              ]
              crop_boxes.append(box)
              layer_idxs.append(i_layer + 1)
  
      return crop_boxes, layer_idxs
  
imports: import math
  from copy import deepcopy
  from itertools import product
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
  from ...image_transforms import convert_to_rgb, pad, resize, to_channel_dimension_format
  from ...image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, ChannelDimension, ImageInput, PILImageResampling, get_image_size, infer_channel_dimension_format, is_scaled_image, make_list_of_images, to_numpy_array, valid_images
  from ...utils import TensorType, is_tf_available, is_torch_available, is_torchvision_available, logging, requires_backends
label_desc: Use image node_id 6 for calling a global function with example usage: _generate_per_layer_crops(crop_n_layers, overlap_ratio, original_size) and returns: crop_boxes,  layer_idxs