code: def write_mapping(filename: str, sym2id: Dict[str, int]) -> None:
      """Write a symbol to ID mapping to a file.
      Note:
        No need to implement `read_mapping` as it can be done
        through :func:`k2.SymbolTable.from_file`.
      Args:
        filename:
          Filename to save the mapping.
        sym2id:
          A dict mapping symbols to IDs.
      Returns:
        Return None.
      """
      with open(filename, "w", encoding="utf-8") as f:
          for sym, i in sym2id.items():
              f.write(f"{sym} {i}\n")
  
file_path: espnet/egs2/reverb/asr1/pyscripts/k2/prepare_lang.py
imports: import argparse
  import math
  from collections import defaultdict
  from pathlib import Path
  from typing import Any, Dict, List, Tuple
  import k2
  import torch
  from icefall.lexicon import read_lexicon, write_lexicon
  from espnet2.utils.types import str2bool
label_desc: Use image node_id 2 for calling a global function with example usage: write_mapping(filename, sym2id) without return types