code: def _plot_legend(class_names, label, prediction):
      colors = ["black"]
      colors.extend(["red"] if label is not None else [])
      colors.extend(["blue"] if prediction is not None else [])
  
      markers = [None]
      markers.extend(["s"] if label is not None else [])
      markers.extend(["s"] if prediction is not None else [])
  
      labels = [r"$\bf{Legend}$"]
      labels.extend(["given label"] if label is not None else [])
      labels.extend(
          ["predicted label"] if prediction is not None else []
      )
  
      if class_names:
          colors += ["black"] + ["black"] * min(
              len(class_names), MAX_CLASS_TO_SHOW
          )
          markers += [None] + [
              f"${class_key}$" for class_key in class_names.keys()
          ]
          labels += [r"$\bf{classes}$"] + list(class_names.values())
  
      try:
          import matplotlib.pyplot as plt
      except ImportError as e:
          raise ImportError(
              "This functionality requires matplotlib. Install it via: `pip install matplotlib`"
          )
  
      f = lambda m, c: plt.plot([], [], marker=m, color=c, ls="none")[0]
      handles = [
          f(marker, color) for marker, color in zip(markers, colors)
      ]
      legend = plt.legend(
          handles,
          labels,
          bbox_to_anchor=(1.04, 0.05),
          loc="lower left",
          borderaxespad=0,
      )
  
      return legend, plt
  
imports: from multiprocessing import Pool
  from typing import Optional, Any, Dict, Tuple, Union, List, TYPE_CHECKING, TypeVar, DefaultDict
  import numpy
  import collections
  from cleanlab.internal.constants import MAX_CLASS_TO_SHOW, ALPHA, EPSILON, TINY_VALUE
  from cleanlab.object_detection.filter import _filter_by_class, _calculate_true_positives_false_positives
  from cleanlab.object_detection.rank import _get_valid_inputs_for_compute_scores, _separate_prediction, _separate_label, _get_prediction_type
  from cleanlab.internal.object_detection_utils import bbox_xyxy_to_xywh
label_desc: Use image node_id 15 for calling a global function with example usage: _plot_legend(class_names, label, prediction) and returns: legend,  plt