code: def clip_boxes(
      boxes: torch.Tensor | NDArray[t.Any], shape: tuple[int, ...]
  ) -> None:
      # Clip boxes (xyxy) to image shape (height, width)
      if isinstance(boxes, torch.Tensor):  # faster individually
          boxes[..., 0].clamp_(0, shape[1])  # x1
          boxes[..., 1].clamp_(0, shape[0])  # y1
          boxes[..., 2].clamp_(0, shape[1])  # x2
          boxes[..., 3].clamp_(0, shape[0])  # y2
      else:  # np.array (faster grouped)
          boxes[..., [0, 2]] = boxes[..., [0, 2]].clip(
              0, shape[1]
          )  # x1, x2
          boxes[..., [1, 3]] = boxes[..., [1, 3]].clip(0, shape[0])
  
imports: from __future__ import annotations
  import json
  import os
  import time
  import typing
  from pathlib import Path
  import attr
  import cv2
  import numpy
  import torch
  import torchvision
  from PIL import Image
label_desc: Use image node_id 9 for calling a global function with example usage: clip_boxes(boxes, shape) without return types