code: def draw_label(
      img: np.ndarray,
      label: Union[int, str],
      score: Optional[float],
      color: Union[np.ndarray, list, tuple],
      border_color: Union[np.ndarray, list, tuple],
      class_map: Optional[ClassMap] = None,
      bbox=None,
      mask=None,
      font: Union[int, os.PathLike, None] = None,
      font_size: Union[int, float] = 12,
      prettify: bool = True,
      prettify_func: Callable = str.capitalize,
      return_as_pil_img=False,
      pad_width_factor=0.02,
      pad_height_factor=0.005,
      thin_border=True,
      x: Optional[int] = None,
      y: Optional[int] = None,
      prefix: str = "",
  ) -> Union[np.ndarray, PIL.Image.Image]:
      # finds label position based on bbox or mask
      if x is None or y is None:
          # print(f"X: {x}, Y: {y}")
          if bbox is not None:
              x, y, _, _ = bbox.xyxy
          elif mask is not None:
              y, x = np.unravel_index(
                  mask.data.argmax(), mask.data.shape
              )
          else:
              x, y = 0, 0
  
      if class_map is not None:
          if isinstance(label, int):
              # TODO: This may never get triggered because we're looping
              # over composite.labels which is a list of strings
              caption = class_map.get_by_id(label)
          else:
              caption = label
      else:
          caption = str(label)
      if prettify:
          # We could introduce a callback here for more complex label renaming
          caption = str(prefix) + str(caption)
          caption = prettify_func(caption)
  
      # Append label confidence to caption if applicable
      if score is not None:
          if prettify:
              score = f"{score * 100: .2f}%"
          caption = f"{caption}: {score}"
  
      if not Path(font).exists():
          # PIL throws cryptic errors for wrong filepaths, so let's catch it earlier here
          raise FileNotFoundError(f"{font} file doesn't exist")
      return _draw_label(
          img=img,
          caption=caption,
          x=x,
          y=y,
          color=color,
          border_color=border_color,
          font_path=font,
          font_size=int(font_size),
          return_as_pil_img=return_as_pil_img,
          pad_width_factor=pad_width_factor,
          pad_height_factor=pad_height_factor,
          thin_border=thin_border,
      )
  
file_path: icevision/icevision/visualize/draw_data.py
imports: from icevision.imports import *
  from icevision.data import *
  from icevision.core import *
  from icevision.visualize.utils import *
  from matplotlib.colors import LinearSegmentedColormap
  from PIL import Image, ImageFont, ImageDraw
  import PIL
label_desc: Use image node_id 2 for calling a global function with example usage: draw_label(img, label, score, color, border_color, class_map, bbox, mask, font, font_size, prettify, prettify_func, return_as_pil_img, pad_width_factor, pad_height_factor, thin_border, x, y, prefix) and returns: _draw_label