code: def add_text_with_bg_color(
      im: np.ndarray,
      text: str,
      tl: tuple,
      bg_color: tuple,
      alpha: float,
      font,
      text_scale: float,
      text_thickness: int,
      text_vert_padding: int = None,
  ):
      """
      Add text to im with background color
  
      Parameters
      ----------
      im
          np.ndarray: the image to add text on
      text
          string: the text content
      tl
          tuple: top left corner of the text region, tl = (x1, y1)
      bg_color
          tuple: the color of the background, e.g. (0, 0, 0)
      alpha
          float: the opacity of the background
      font
          the font of the text, e.g. cv2.FONT_HERSHEY_DUPLEX
      text_scale
          float: the scale (font size) of the text, e.g. 0.75
      text_thickness
          int: the font weight of the text, e.g. 1
      text_vert_padding
          int: vertical padding of the text on each side
      Returns
      -------
      an np.ndarray of image with added text
      """
      try:
          import cv2
      except:
          raise ImportError(
              "No module named: cv2. Please install cv2 by 'pip install opencv-python'"
          )
  
      x1, y1 = tl
  
      overlay = im.copy()
      text_size, _ = cv2.getTextSize(
          text, font, float(text_scale), text_thickness
      )
      text_w, text_h = text_size
  
      text_vert_padding = (
          text_vert_padding if text_vert_padding else int(text_h * 0.1)
      )
  
      y1 = max(y1 - text_h - text_vert_padding * 2, 0)
  
      cv2.rectangle(
          overlay,
          (x1, y1),
          (x1 + text_w, y1 + text_h + text_vert_padding * 2),
          bg_color,
          -1,
      )
      im = cv2.addWeighted(overlay, alpha, im, 1 - alpha, 0)
      cv2.putText(
          im,
          text,
          (x1, y1 + text_h + text_vert_padding),
          font,
          text_scale,
          (255, 255, 255),
          thickness=text_thickness,
      )
      return im
  
imports: import json
  import logging
  import os
  import warnings
  from pathlib import Path
  from typing import Dict, Iterable, List, Optional, Union
  import defusedxml.ElementTree
  import numpy
  import pandas
  import PIL
  from torchmetrics.detection.mean_ap import MeanAveragePrecision
  from ..constants import BBOX, LABEL, MAP, MAP_50, MAP_75, MAP_LARGE, MAP_MEDIUM, MAP_SMALL, MAR_1, MAR_10, MAR_100, MAR_LARGE, MAR_MEDIUM, MAR_SMALL, MEAN_AVERAGE_PRECISION
  from .download import download, is_url
label_desc: Use image node_id 33 for calling a global function with example usage: add_text_with_bg_color(im, text, tl, bg_color, alpha, font, text_scale, text_thickness, text_vert_padding) and returns: im