code: def bbox2poly(bbox: ArrayLike, mode: str = "xyxy") -> np.array:
      """Converting a bounding box to a polygon.
  
      Args:
          bbox (ArrayLike): A bbox. In any form can be accessed by 1-D indices.
           E.g. list[float], np.ndarray, or torch.Tensor. bbox is written in
              [x1, y1, x2, y2].
          mode (str): Specify the format of bbox. Can be 'xyxy' or 'xywh'.
              Defaults to 'xyxy'.
  
      Returns:
          np.array: The converted polygon [x1, y1, x2, y1, x2, y2, x1, y2].
      """
      assert len(bbox) == 4
      if mode == "xyxy":
          x1, y1, x2, y2 = bbox
          poly = np.array([x1, y1, x2, y1, x2, y2, x1, y2])
      elif mode == "xywh":
          x, y, w, h = bbox
          poly = np.array([x, y, x + w, y, x + w, y + h, x, y + h])
      else:
          raise NotImplementedError("Not supported mode.")
  
      return poly
  
file_path: mmocr/mmocr/utils/bbox_utils.py
imports: from typing import List, Tuple
  import numpy
  from shapely.geometry import LineString, Point
  from mmocr.utils.check_argument import is_type_list
  from mmocr.utils.point_utils import point_distance, points_center
  from mmocr.utils.typing_utils import ArrayLike
label_desc: Use image node_id 3 for calling a global function with example usage: bbox2poly(bbox, mode) and returns: poly