code: def poly2bbox(polygon: ArrayLike) -> np.array:
      """Converting a polygon to a bounding box.
  
      Args:
           polygon (ArrayLike): A polygon. In any form can be converted
               to an 1-D numpy array. E.g. list[float], np.ndarray,
               or torch.Tensor. Polygon is written in
               [x1, y1, x2, y2, ...].
  
       Returns:
           np.array: The converted bounding box [x1, y1, x2, y2]
      """
      assert len(polygon) % 2 == 0
      polygon = np.array(polygon, dtype=np.float32)
      x = polygon[::2]
      y = polygon[1::2]
      return np.array([min(x), min(y), max(x), max(y)])
  
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 3 for calling a global function with example usage: poly2bbox(polygon) and returns: np