code: def template_rewrite(
      template_path: Path, context: Dict[str, str]
  ) -> None:
      with template_path.open("r") as fin:
          temp_path = Path(str(template_path) + ".temp")
          with temp_path.open("w") as fout:
              matching = False
              for line in fin:
                  if matching:
                      if END_MARKER.search(line):
                          matching = False
                  else:
                      m = START_MARKER.search(line)
                      if m:
                          matching = True
                          key = m.group(1)
                          fout.write(line)
                          fout.write(context[key])
                          continue
                  if not matching:
                      fout.write(line)
          temp_path.replace(template_path)
  
imports: import re
  from itertools import chain
  from pathlib import Path
  from typing import Dict
label_desc: Use image node_id 1 for calling a global function with example usage: template_rewrite(template_path, context) without return types