code: def flatten_results_dict(results):
      """
      Expand a hierarchical dict of scalars into a flat dict of scalars.
      If results[k1][k2][k3] = v, the returned dict will have the entry
      {"k1/k2/k3": v}.
  
      Args:
          results (dict):
      """
      r = {}
      for k, v in results.items():
          if isinstance(v, Mapping):
              v = flatten_results_dict(v)
              for kk, vv in v.items():
                  r[k + "/" + kk] = vv
          else:
              r[k] = v
      return r
  
file_path: detectron2/detectron2/evaluation/testing.py
imports: import logging
  import numpy
  import pprint
  import sys
  from collections.abc import Mapping
label_desc: Use image node_id 3 for calling a global function with example usage: flatten_results_dict(results) and returns: r