code: def launch(experiment_config: det.ExperimentConfig) -> int:
      entrypoint = experiment_config.get_entrypoint()
  
      if isinstance(
          entrypoint, str
      ) and det.util.match_legacy_trial_class(entrypoint):
          # Legacy entrypoint ("model_def:Trial") detected
          entrypoint = [
              "python3",
              "-m",
              "determined.launch.horovod",
              "--autohorovod",
              "--trial",
              entrypoint,
          ]
  
      if isinstance(entrypoint, str):
          entrypoint = ["sh", "-c", entrypoint]
  
      # Signals we want to forward from wrapper process to the child
      sig_names = [
          "SIGINT",
          "SIGTERM",
          "SIGHUP",
          "SIGUSR1",
          "SIGUSR2",
          "SIGWINCH",
          "SIGBREAK",
      ]
  
      if (
          os.environ.get("DET_RESOURCES_TYPE")
          == prep_container.RESOURCES_TYPE_SLURM_JOB
      ):
          # SLURM sends SIGTERM to notify of pending preemption, so we register a custom
          # handler to intercept it in the chief rank, and ignore in others.   We invoke
          # trigger_preemption to cause a checkpoint and clean exit (given enough time).
          signal.signal(signal.SIGTERM, trigger_preemption)
          # Drop SIGTERM from forwarding so that we handle it in trigger_preemption
          sig_names.remove("SIGTERM")
  
      logger.info(f"Launching: {entrypoint}")
  
      p = subprocess.Popen(entrypoint)
      # Convert from signal names to Signal enums because SIGBREAK is windows-specific
      forwaded_signals = [
          getattr(signal, name)
          for name in sig_names
          if hasattr(signal, name)
      ]
      with det.util.forward_signals(p, *forwaded_signals):
          return p.wait()
  
file_path: determined/harness/determined/exec/launch.py
imports: import json
  import logging
  import os
  import signal
  import subprocess
  import sys
  import types
  import determined
  import determined.common
  from determined.common import api, constants, storage
  from determined.exec import prep_container
label_desc: Use image node_id 2 for calling a global function with example usage: launch(experiment_config) and returns: p