code: def box_crop(
      boxes: np.ndarray,
      labels: np.ndarray,
      scores: np.ndarray,
      crop: List[int],
      img_shape: List[int],
  ) -> Tuple:
      """Crop the boxes ,labels, scores according to the given shape"""
  
      x, y, w, h = map(float, crop)
      im_w, im_h = map(float, img_shape)
  
      boxes = boxes.copy()
      boxes[:, 0], boxes[:, 2] = (
          boxes[:, 0] - boxes[:, 2] / 2
      ) * im_w, (boxes[:, 0] + boxes[:, 2] / 2) * im_w
      boxes[:, 1], boxes[:, 3] = (
          boxes[:, 1] - boxes[:, 3] / 2
      ) * im_h, (boxes[:, 1] + boxes[:, 3] / 2) * im_h
  
      crop_box = np.array([x, y, x + w, y + h])
      centers = (boxes[:, :2] + boxes[:, 2:]) / 2.0
      mask = np.logical_and(
          crop_box[:2] <= centers, centers <= crop_box[2:]
      ).all(axis=1)
  
      boxes[:, :2] = np.maximum(boxes[:, :2], crop_box[:2])
      boxes[:, 2:] = np.minimum(boxes[:, 2:], crop_box[2:])
      boxes[:, :2] -= crop_box[:2]
      boxes[:, 2:] -= crop_box[:2]
  
      mask = np.logical_and(
          mask, (boxes[:, :2] < boxes[:, 2:]).all(axis=1)
      )
      boxes = boxes * np.expand_dims(mask.astype("float32"), axis=1)
      labels = labels * mask.astype("float32")
      scores = scores * mask.astype("float32")
      boxes[:, 0], boxes[:, 2] = (boxes[:, 0] + boxes[:, 2]) / 2 / w, (
          boxes[:, 2] - boxes[:, 0]
      ) / w
      boxes[:, 1], boxes[:, 3] = (boxes[:, 1] + boxes[:, 3]) / 2 / h, (
          boxes[:, 3] - boxes[:, 1]
      ) / h
  
      return boxes, labels, scores, mask.sum()
  
imports: import os
  from typing import Callable, Union, List, Tuple
  import cv2
  import paddle
  import PIL
  import numpy
  import paddle.nn.functional
  from scipy.sparse import csr_matrix
label_desc: Use image node_id 3 for calling a global function with example usage: box_crop(boxes, labels, scores, crop, img_shape) and returns: boxes,  labels,  scores,  mask