code: def _temp_discovery_script(logfile, discovery_schedule):
      with temppath() as discovery_script:
          with open(discovery_script, "w") as f:
              f.write(
                  DISCOVERY_SCRIPT_TEMPLATE.format(logfile=logfile)
                  + os.linesep
              )
              for i, schedule_step in enumerate(discovery_schedule):
                  f.write(
                      _get_discovery_lines(
                          schedule_step,
                          start=i == 0,
                          end=i == len(discovery_schedule) - 1,
                      )
                  )
          os.chmod(discovery_script, 0o755)
          yield discovery_script
  
imports: import contextlib
  import json
  import os
  import sys
  from typing import Callable
  import mock
  import pytest
  from horovod.runner.common.util import config_parser
  from horovod.runner.elastic import constants
  from horovod.runner.launch import parse_args, _run_elastic
  from common import override_args, temppath
label_desc: Use image node_id 2 for calling a global function with example usage: _temp_discovery_script(logfile, discovery_schedule) without return types