code: def flatten(schema: Definition) -> FlatIntermediateDefinition:
      """See types.py for an explanation of nested vs. flat definitions."""
      result: FlatIntermediateDefinition = {}
      _flatten(key_prefix=(), sub_schema=schema, result=result)
  
      # Ensure that we produced a valid flat definition.
      for k, v in result.items():
          assert isinstance(k, tuple)
          assert all(isinstance(ki, str) for ki in k)
          assert isinstance(v, (TimerArgs, GroupedBenchmark))
      return result
  
file_path: pytorch/benchmarks/instruction_counts/core/utils.py
imports: import atexit
  import re
  import shutil
  import textwrap
  from typing import List, Optional, Tuple
  from torch.utils.benchmark.utils.common import _make_temp_dir
  from core.api import GroupedBenchmark, TimerArgs
  from core.types import Definition, FlatIntermediateDefinition, Label
label_desc: Use image node_id 3 for calling a global function with example usage: flatten(schema) and returns: result