code: def poly2shapely(polygon: ArrayLike) -> Polygon:
      """Convert a polygon to shapely.geometry.Polygon.
  
      Args:
          polygon (ArrayLike): A set of points of 2k shape.
  
      Returns:
          polygon (Polygon): A polygon object.
      """
      polygon = np.array(polygon, dtype=np.float32)
      assert polygon.size % 2 == 0 and polygon.size >= 6
  
      polygon = polygon.reshape([-1, 2])
      return Polygon(polygon)
  
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 4 for calling a global function with example usage: poly2shapely(polygon) and returns: Polygon