code: def main():
      args = parse_args()
  
      if args.version:
          print(bluefog.__version__)
          exit(0)
  
      def handler(signum, frame):
          _maybe_kill_ipcontroller_process(args.profile)
          raise KeyboardInterrupt
  
      signal.signal(signal.SIGINT, handler)
  
      env = os.environ.copy()
      # No longer needed after using condition variable.
      # env['BLUEFOG_CYCLE_TIME'] = str(20)  # Increase the cycle time
  
      # action of stop
      if args.action == "stop":
          # TODO(ybc) How to stop it both controller and engines properly?
          # In multiple machine env, we also need to remove engine.json and client.json file.
          ipcluster_stop_command = (
              "ipcluster stop --profile {profile}".format(
                  profile=args.profile
              )
          )
          subprocess.run(
              ipcluster_stop_command,
              shell=True,
              env=env,
              capture_output=True,
          )
          _maybe_kill_ipcontroller_process(args.profile)
          _maybe_kill_ipengine_processes(args.profile)
          exit(0)
  
      # action of start
      (
          hosts_arg,
          all_host_names,
      ) = network_util.get_hosts_arg_and_hostnames(args)
      remote_host_names = network_util.filter_local_addresses(
          all_host_names
      )
  
      if not env_util.is_open_mpi_installed():
          raise Exception(
              "ibfrun convenience script currently only supports Open MPI.\n"
              "Please Install Open MPI 4.0.0+ and re-install Bluefog."
          )
  
      if not env_util.is_ipyparallel_installed():
          raise Exception(
              "ibfrun is based on the ipyparallel package. Please install it in your\n"
              "system like `pip install ipyparallel` first, then run ibfrun again."
          )
  
      try:
          if not remote_host_names:
              local_machine_launch(args, env)
          else:
              multiple_machines_launch(
                  args,
                  env,
                  all_host_names=all_host_names,
                  hosts_arg=hosts_arg,
                  remote_host_names=remote_host_names,
              )
      except Exception as e:
          print("Fail to launch ibfrun. Error: ", e)
      finally:
          _maybe_kill_ipcontroller_process(args.profile)
          if not remote_host_names:
              time.sleep(1.0)
              _maybe_kill_ipengine_processes(args.profile)
  
imports: import argparse
  import json
  import os
  import multiprocessing
  import signal
  import subprocess
  import time
  from typing import Dict, List
  import ipyparallel
  import bluefog
  from bluefog.run import env_util, network_util, horovod_driver
label_desc: Use image node_id 17 for calling a global function with example usage: main() without return types