code: def crop_bboxes_from_image(
      img_path: Union[str, Path], geoms: np.ndarray
  ) -> List[np.ndarray]:
      """Crop a set of bounding boxes from an image
  
      Args:
      ----
          img_path: path to the image
          geoms: a array of polygons of shape (N, 4, 2) or of straight boxes of shape (N, 4)
  
      Returns:
      -------
          a list of cropped images
      """
      img: np.ndarray = np.array(Image.open(img_path).convert("RGB"))
      # Polygon
      if geoms.ndim == 3 and geoms.shape[1:] == (4, 2):
          return extract_rcrops(img, geoms.astype(dtype=int))
      if geoms.ndim == 2 and geoms.shape[1] == 4:
          return extract_crops(img, geoms.astype(dtype=int))
      raise ValueError("Invalid geometry format")
  
file_path: doctr/doctr/datasets/utils.py
imports: import string
  import unicodedata
  from collections.abc import Sequence
  from functools import partial
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Tuple, TypeVar, Union
  from typing import Sequence
  import numpy
  from PIL import Image
  from doctr.io.image import get_img_shape
  from doctr.utils.geometry import convert_to_relative_coords, extract_crops, extract_rcrops
  from .vocabs import VOCABS
label_desc: Use image node_id 6 for calling a global function with example usage: crop_bboxes_from_image(img_path, geoms) and returns: extract_rcrops, extract_crops