code: def driver_fn(
      all_host_names, local_host_names, ssh_port=None, verbose=False
  ):
      """
      launches the service service, launches the task service on each worker and
      have them register with the service service. Each worker probes all the
      interfaces of the worker index + 1 (in a ring manner) and only keeps the
      routed interfaces. Function returns the intersection of the set of all the
      routed interfaces on all the workers.
      :param all_host_names: list of addresses. for example,
          ['worker-0','worker-1']
          ['10.11.11.11', '10.11.11.12']
      :type all_host_names: list(string)
      :param local_host_names: host names that resolve into a local addresses.
      :type local_host_names: set
      :param tmout:
      :type tmout: horovod.spark.util.timeout.Timeout
      :param verbose:
      :type verbose: bool
      :return: example: ['eth0', 'eth1']
      :rtype: list[string]
      """
      key = secret.make_secret_key()
      tmout = timeout.Timeout(
          int(os.getenv("BLUEFOG_START_TIMEOUT", "600"))
      )
      num_hosts = len(all_host_names)
      # Launch a TCP server called service service on the host running bluefogrun.
      driver = driver_service.HorovodRunDriverService(num_hosts, key)
      if verbose:
          print("Launched bluefog run server.")
      # Have all the workers register themselves with the service service.
      _launch_task_servers(
          all_host_names,
          local_host_names,
          driver.addresses(),
          num_hosts,
          tmout,
          key,
          ssh_port,
      )
      if verbose:
          print("Attempted to launch bluefog task servers.")
      try:
          # wait for all the hosts to register with the service service.
          if verbose:
              print("Waiting for the hosts to acknowledge.")
          driver.wait_for_initial_registration(tmout)
          tasks = [
              task_service.HorovodRunTaskClient(
                  index, driver.task_addresses_for_driver(index), key
              )
              for index in range(num_hosts)
          ]
          # Notify all the drivers that the initial registration is complete.
          for task in tasks:
              task.notify_initial_registration_complete()
          if verbose:
              print(
                  "Notified all the hosts that the registration is complete."
              )
          # Each worker should probe the interfaces of the next worker in a ring
          # manner and filter only the routed ones -- it should filter out
          # interfaces that are not really connected to any external networks
          # such as lo0 with address 127.0.0.1.
          if verbose:
              print(
                  "Waiting for hosts to perform host-to-host "
                  "interface checking."
              )
          driver.wait_for_task_to_task_address_updates(tmout)
          if verbose:
              print("Host-to-host interface checking successful.")
          # Determine a set of common interfaces for task-to-task communication.
          common_intfs = set(driver.task_addresses_for_tasks(0).keys())
          for index in range(1, num_hosts):
              common_intfs.intersection_update(
                  driver.task_addresses_for_tasks(index).keys()
              )
          if not common_intfs:
              raise Exception(
                  "Unable to find a set of common task-to-task communication "
                  "interfaces: %s"
                  % [
                      (index, driver.task_addresses_for_tasks(index))
                      for index in range(num_hosts)
                  ]
              )
          return common_intfs
      finally:
          driver.shutdown()
  
file_path: bluefog/bluefog/run/horovod_driver.py
imports: import os
  import sys
  import six
  from bluefog.run.horovodrun.common.util import codec, safe_shell_exec, timeout, secret
  from bluefog.run.horovodrun.driver import driver_service
  from bluefog.run.horovodrun.task import task_service
  from bluefog.run.horovodrun.util import threads
label_desc: Use image node_id 2 for calling a global function with example usage: driver_fn(all_host_names, local_host_names, ssh_port, verbose) and returns: common_intfs