code: def crop_polygon(
      polygon: ArrayLike, crop_box: np.ndarray
  ) -> Union[np.ndarray, None]:
      """Crop polygon to be within a box region.
  
      Args:
          polygon (ndarray): polygon in shape (N, ).
          crop_box (ndarray): target box region in shape (4, ).
  
      Returns:
          np.array or None: Cropped polygon. If the polygon is not within the
              crop box, return None.
      """
      poly = poly_make_valid(poly2shapely(polygon))
      crop_poly = poly_make_valid(poly2shapely(bbox2poly(crop_box)))
      area, poly_cropped = poly_intersection(
          poly, crop_poly, return_poly=True
      )
      if (
          area == 0
          or area is None
          or not isinstance(
              poly_cropped, shapely.geometry.polygon.Polygon
          )
      ):
          return None
      else:
          poly_cropped = poly_make_valid(poly_cropped)
          poly_cropped = np.array(
              poly_cropped.boundary.xy, dtype=np.float32
          )
          poly_cropped = poly_cropped.T
          # reverse poly_cropped to have clockwise order
          poly_cropped = poly_cropped[::-1, :].reshape(-1)
          return poly_cropped
  
imports: import math
  import operator
  from functools import reduce
  from typing import List, Optional, Sequence, Tuple, Union
  import numpy
  import pyclipper
  import shapely
  from mmengine.utils import is_list_of
  from shapely.geometry import MultiPolygon, Polygon
  from mmocr.utils import bbox2poly, valid_boundary
  from mmocr.utils.check_argument import is_2dlist
  from mmocr.utils.typing_utils import ArrayLike
label_desc: Use image node_id 7 for calling a global function with example usage: crop_polygon(polygon, crop_box) and returns: None, poly_cropped