code: def gloo_run_elastic(settings, driver, env, stdout=None, stderr=None):
      """
      Run distributed gloo jobs.
  
      :param settings: Settings for running the distributed jobs.
                       Note: settings.num_proc and settings.hosts must not be None.
      :param driver: The Spark driver service that tasks are connected to.
      :param env: Environment dictionary to use for running gloo jobs.  Can be None.
      :param stdout: Horovod stdout is redirected to this stream.
      :param stderr: Horovod stderr is redirected to this stream.
      """
      if env is None:
          env = {}
  
      # Each thread will use SparkTaskClient to launch the job on each remote host. If an
      # error occurs in one thread, entire process will be terminated. Otherwise,
      # threads will keep running and ssh session.
      command = (
          sys.executable,
          "-m",
          "horovod.spark.task.gloo_exec_fn",
          codec.dumps_base64(driver.addresses()),
          codec.dumps_base64(settings),
      )
  
      # Pass secret key through the environment variables.
      env[secret.HOROVOD_SECRET_KEY] = codec.dumps_base64(settings.key)
  
      # get common interfaces from driver
      nics = driver.get_common_interfaces()
  
      exec_command = _exec_command_fn(
          driver,
          settings.key,
          settings,
          env,
          stdout,
          stderr,
          settings.prefix_output_with_timestamp,
      )
      rendezvous = SparkRendezvousServer(driver, settings.verbose)
      launch_gloo_elastic(
          command,
          exec_command,
          settings,
          env,
          lambda _: nics,
          rendezvous,
          sys.executable,
      )
  
file_path: horovod/horovod/spark/gloo_run.py
imports: import sys
  import time
  from horovod.runner.common.util import codec, secret
  from horovod.runner.gloo_run import launch_gloo, launch_gloo_elastic
  from horovod.spark.driver.rsh import rsh
  from horovod.spark.driver.rendezvous import SparkRendezvousServer
label_desc: Use image node_id 3 for calling a global function with example usage: gloo_run_elastic(settings, driver, env, stdout, stderr) without return types