code: def integration_test(
      tmpdir: Path,
      task_config: Any,
      overrides: List[str],
      prints: Union[str, List[str]],
      expected_outputs: Union[str, List[str]],
      prolog: Union[None, str, List[str]] = None,
      filename: str = "task.py",
      env_override: Optional[Dict[str, str]] = None,
      clean_environment: bool = False,
      generate_custom_cmd: Callable[
          ..., List[str]
      ] = lambda cmd, *args, **kwargs: cmd,
  ) -> str:
      Path(tmpdir).mkdir(parents=True, exist_ok=True)
      if isinstance(expected_outputs, str):
          expected_outputs = [expected_outputs]
      if not isinstance(task_config, Container):
          task_config = OmegaConf.create(task_config)
      if isinstance(prints, str):
          prints = [prints]
      prints = [f'f.write({p} + "\\n")' for p in prints]
  
      s = string.Template(
          """import hydra
  import os
  from hydra.core.hydra_config import HydraConfig
  
  $PROLOG
  
  @hydra.main(version_base=None, config_path='.', config_name='config')
  def experiment(cfg):
      with open("$OUTPUT_FILE", "w") as f:
  $PRINTS
  
  if __name__ == "__main__":
      experiment()
  """
      )
  
      print_code = _get_statements(indent="        ", statements=prints)
      prolog_code = _get_statements(indent="", statements=prolog)
  
      if task_config is not None:
          cfg_file = tmpdir / "config.yaml"
          with open(str(cfg_file), "w") as f:
              f.write("# @package _global_\n")
              OmegaConf.save(task_config, f)
      output_file = str(tmpdir / "output.txt")
      # replace Windows path separator \ with an escaped version \\
      output_file = output_file.replace("\\", "\\\\")
      code = s.substitute(
          PRINTS=print_code,
          OUTPUT_FILE=output_file,
          PROLOG=prolog_code,
      )
      task_file = tmpdir / filename
      task_file.write_text(str(code), encoding="utf-8")
  
      cmd = [sys.executable, str(task_file)]
      orig_dir = os.getcwd()
      try:
          os.chdir(str(tmpdir))
          cmd = generate_custom_cmd(cmd, filename)
          cmd.extend(overrides)
          if clean_environment:
              modified_env = {}
          else:
              modified_env = os.environ.copy()
              if env_override is not None:
                  modified_env.update(env_override)
          subprocess.check_call(cmd, env=modified_env)
  
          with open(output_file) as f:
              file_str = f.read()
              output = str.splitlines(file_str)
  
          if expected_outputs is not None:
              assert len(output) == len(
                  expected_outputs
              ), f"Unexpected number of output lines from {task_file}, output lines:\n\n{file_str}"
              for idx in range(len(output)):
                  assert_regex_match(expected_outputs[idx], output[idx])
          # some tests are parsing the file output for more specialized testing.
          return file_str
      finally:
          os.chdir(orig_dir)
  
imports: import copy
  import logging
  import os
  import re
  import shutil
  import string
  import subprocess
  import sys
  import tempfile
  from contextlib import contextmanager
  from difflib import unified_diff
  from pathlib import Path
  from subprocess import PIPE, Popen
  from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
  from omegaconf import Container, DictConfig, OmegaConf
  from hydra._internal.hydra import Hydra
  from hydra._internal.utils import detect_task_name
  from hydra.core.global_hydra import GlobalHydra
  from hydra.core.utils import JobReturn, validate_config_path
  from hydra.types import TaskFunction
label_desc: Use image node_id 8 for calling a global function with example usage: integration_test(tmpdir, task_config, overrides, prints, expected_outputs, prolog, filename, env_override, clean_environment, generate_custom_cmd) and returns: file_str