code: def _flatten_tree(t, depth=0):
      flat = []
      for name, st in t.items():
          measures = st.pop(None, None)
          flat.append([depth, name, measures])
          flat.extend(_flatten_tree(st, depth=depth + 1))
      return flat
  
imports: import functools
  from collections import OrderedDict, defaultdict, namedtuple
  from typing import Any, List, NamedTuple, Optional, Tuple
  import torch
  import torch.profiler
label_desc: Use image node_id 2 for calling a global function with example usage: _flatten_tree(t, depth) and returns: flat