code: def tabulate_metrics(
      metrics, headers=None, newline=True, digits=None, title=None
  ):
      # TODO: Fine granularity of digit control
      if headers is None:
          headers = ["Metric", "Value"]
      metrics = copy.deepcopy(metrics)
      if digits is not None:
          metrics = set_digits(metrics, digits)
      tab = tabulate(metrics.items(), headers=headers)
      if title is not None:
          tab = title + "\n\n" + tab
      if newline:
          tab = "\n" + tab
      return tab
  
file_path: PaddleSeg/contrib/PanopticSeg/paddlepanseg/utils/misc.py
imports: import copy
  import importlib
  from collections.abc import Mapping, Sequence
  from contextlib import contextmanager
  from tabulate import tabulate
  from paddleseg.utils import logger
label_desc: Use image node_id 2 for calling a global function with example usage: tabulate_metrics(metrics, headers, newline, digits, title) and returns: tab