code: def run_in_tmp_dir(code):
      """Executes code in temporary working directory."""
      cwd = os.getcwd()
      with tempfile.TemporaryDirectory() as tmp_dir:
          os.chdir(tmp_dir)
  
          # Use runpy instead of exec here because a) it doesn't interfere with
          # globals and b) it gives better error messages.
          with open("code.py", "w") as f:
              f.write(code)
          try:
              runpy.run_path("code.py")
          finally:
              os.chdir(cwd)
  
file_path: traingenerator/tests/test_templates.py
imports: import sys
  import os
  import yaml
  import itertools
  from jinja2 import Environment, FileSystemLoader
  import pytest
  import tempfile
  import runpy
  import shutil
  import copy
label_desc: Use image node_id 1 for calling a global function with example usage: run_in_tmp_dir(code) without return types