code: def metrics_table(
      metrics,
      all_branches: bool = False,
      all_tags: bool = False,
      all_commits: bool = False,
      precision: Optional[int] = None,
      round_digits: bool = False,
  ):
      from dvc.utils.diff import format_dict
      from dvc.utils.flatten import flatten
  
      td = TabularData(["Revision", "Path"], fill_value="-")
  
      for branch, val in metrics.items():
          for fname, metric in val.get("data", {}).items():
              row_data: Dict[str, str] = {
                  "Revision": branch,
                  "Path": fname,
              }
              metric = metric.get("data", {})
              flattened = (
                  flatten(format_dict(metric))
                  if isinstance(metric, dict)
                  else {"": metric}
              )
              row_data.update(
                  {
                      k: _format_field(v, precision, round_digits)
                      for k, v in flattened.items()
                  }
              )
              td.row_from_dict(row_data)
  
      rev, path, *metrics_headers = td.keys()
      td.project(rev, path, *sorted(metrics_headers))
  
      if not any([all_branches, all_tags, all_commits]):
          td.drop("Revision")
  
      return td
  
imports: from collections import abc
  from itertools import chain, repeat, zip_longest
  from operator import itemgetter
  from typing import TYPE_CHECKING, Any, Dict, ItemsView, Iterable, Iterator, List, Mapping, MutableSequence, Optional, Sequence, Set, Tuple, Union, overload
  from funcy import reraise
label_desc: Use image node_id 6 for calling a global function with example usage: metrics_table(metrics, all_branches, all_tags, all_commits, precision, round_digits) and returns: td