code: def polygon_patch(
      geometry: np.ndarray,
      page_dimensions: Tuple[int, int],
      label: Optional[str] = None,
      color: Tuple[float, float, float] = (0, 0, 0),
      alpha: float = 0.3,
      linewidth: int = 2,
      fill: bool = True,
      preserve_aspect_ratio: bool = False,
  ) -> patches.Polygon:
      """Create a matplotlib polygon patch for the element
  
      Args:
      ----
          geometry: bounding box of the element
          page_dimensions: dimensions of the Page in format (height, width)
          label: label to display when hovered
          color: color to draw box
          alpha: opacity parameter to fill the boxes, 0 = transparent
          linewidth: line width
          fill: whether the patch should be filled
          preserve_aspect_ratio: pass True if you passed True to the predictor
  
      Returns:
      -------
          a polygon Patch
      """
      if not geometry.shape == (4, 2):
          raise ValueError("invalid geometry format")
  
      # Unpack
      height, width = page_dimensions
      geometry[:, 0] = geometry[:, 0] * (
          max(width, height) if preserve_aspect_ratio else width
      )
      geometry[:, 1] = geometry[:, 1] * (
          max(width, height) if preserve_aspect_ratio else height
      )
  
      return patches.Polygon(
          geometry,
          fill=fill,
          linewidth=linewidth,
          edgecolor=(*color, alpha),
          facecolor=(*color, alpha),
          label=label,
      )
  
imports: import colorsys
  from copy import deepcopy
  from typing import Any, Dict, List, Optional, Tuple, Union
  import cv2
  import matplotlib.patches
  import matplotlib.pyplot
  import mplcursors
  import numpy
  from matplotlib.figure import Figure
  from PIL import Image, ImageDraw
  from unidecode import unidecode
  from .common_types import BoundingBox, Polygon4P
  from .fonts import get_font
label_desc: Use image node_id 2 for calling a global function with example usage: polygon_patch(geometry, page_dimensions, label, color, alpha, linewidth, fill, preserve_aspect_ratio) and returns: patches