code: def crop_image(img, rect):
      x, y, w, h = rect
  
      left = abs(x) if x < 0 else 0
      top = abs(y) if y < 0 else 0
      right = (
          abs(img.shape[1] - (x + w)) if x + w >= img.shape[1] else 0
      )
      bottom = (
          abs(img.shape[0] - (y + h)) if y + h >= img.shape[0] else 0
      )
  
      if img.shape[2] == 4:
          color = [0, 0, 0, 0]
      else:
          color = [0, 0, 0]
      new_img = cv2.copyMakeBorder(
          img,
          top,
          bottom,
          left,
          right,
          cv2.BORDER_CONSTANT,
          value=color,
      )
  
      x = x + left
      y = y + top
  
      return new_img[y : (y + h), x : (x + w), :]
  
imports: import os
  import random
  import numpy
  from PIL import Image, ImageOps
  from PIL.ImageFilter import GaussianBlur
  import cv2
  import torch
  import json
  from torch.utils.data import Dataset
  import torchvision.transforms
label_desc: Use image node_id 1 for calling a global function with example usage: crop_image(img, rect) and returns: new_img