code: def format_results(
      results: Dict[str, Tuple[float]],
      label: str,
      full: bool = True,
      errors: bool = False,
      table_layout: str = "fancy_grid",
  ):
      """
      Util to format and print the results.
  
      Format results in tabular format.
      :param results: the dictionary output by the get_metric() method
      :param label: the title of the table to print
      :param full: is true, prints the results of all the labels.\
              Otherwise prints just the average among them
      :param errors: if true, prints TPs, FPs and FNs
      :param table_layout: the table layout.\
              Available: all those from `tabulate`, `csv` and `tsv`.
      :return: the formatted table as string
      """
      if errors:
          threshold = 100
      else:
          threshold = 4
      header = [
          label.capitalize(),
          "Precision",
          "Recall",
          "F-Measure",
          "TP",
          "FP",
          "FN",
      ][:threshold]
      table = [["overall".upper(), *results.pop("overall")][:threshold]]
      if full:
          for label in results:
              table.append([label, *results[label]][:threshold])
      if table_layout in {"csv", "tsv"}:
          for i, row in enumerate(table):
              for j, item in enumerate(row):
                  table[i][j] = str(item)
          return (
              SEPARATORS[table_layout].join(header)
              + "\n"
              + "\n".join(
                  [SEPARATORS[table_layout].join(row) for row in table]
              )
          )
      if table_layout not in tabulate.tabulate_formats:
          logger.warning(
              "{} non valid as table format. Using ``fancy_grid``".format(
                  table_layout
              )
          )
          table_layout = "fancy_grid"
  
      return tabulate.tabulate(
          table,
          headers=header,
          tablefmt=table_layout,
          floatfmt=("", ".4f", ".4f", ".4f", ".0f", ".1f", ".1f"),
      )
  
file_path: espnet/egs2/slurp_entity/asr1/local/evaluation/util.py
imports: import json
  import logging
  import os
  from typing import Any, Dict, Tuple
  import tabulate
  from progress.bar import Bar
label_desc: Use image node_id 4 for calling a global function with example usage: format_results(results, label, full, errors, table_layout) and returns: tabulate, unknown