code: def _create_text_labels(
      classes: List[int],
      scores: List[float],
      class_names: List[str],
      ground_truth: bool = False,
  ) -> List[str]:
      """
      Create text labels.
      Args:
          classes (list[int]): a list of class ids for each example.
          scores (list[float] or None): list of scores for each example.
          class_names (list[str]): a list of class names, ordered by their ids.
          ground_truth (bool): whether the labels are ground truth.
      Returns:
          labels (list[str]): formatted text labels.
      """
      try:
          labels = [class_names.get(c, "n/a") for c in classes]
      except IndexError:
          logger.error(
              "Class indices get out of range: {}".format(classes)
          )
          return None
  
      if ground_truth:
          labels = ["[{}] {}".format("GT", label) for label in labels]
      elif scores is not None:
          assert len(classes) == len(scores)
          labels = [
              "[{:.2f}] {}".format(s, label)
              for s, label in zip(scores, labels)
          ]
      return labels
  
imports: from __future__ import annotations
  import itertools
  import logging
  from types import SimpleNamespace
  from typing import Dict, List, Optional, Tuple, Union
  import matplotlib.pyplot
  import numpy
  import torch
  from detectron2.utils.visualizer import Visualizer
label_desc: Use image node_id 1 for calling a global function with example usage: _create_text_labels(classes, scores, class_names, ground_truth) and returns: labels, None