code: def main():
      args = parse_args()
  
      ray.init(address=args.ray_address)
  
      # world size in terms of number of processes
      dist_world_size = args.nproc_per_node * args.nnodes
  
      wait_for_gpus(dist_world_size)
  
      # Set up Ray distributed actors.
      actor = ray.remote(num_cpus=1, num_gpus=args.nproc_per_node)(
          NodeLaunchActor
      )
      workers = [actor.remote() for i in range(args.nnodes)]
  
      # Set worker 0 as the master
      master_addr = ray.get(workers[0].get_node_ip.remote())
      master_port = ray.get(workers[0].find_free_port.remote())
  
      unfinished = [
          worker.run.remote(
              master_addr=master_addr,
              master_port=master_port,
              node_rank=i,
              dist_world_size=dist_world_size,
              args=args,
          )
          for i, worker in enumerate(workers)
      ]
  
      try:
          while len(unfinished) > 0:
              finished, unfinished = ray.wait(unfinished)
              finished = ray.get(finished)
      except Exception as inst:
          logging.exception("An error occurred:")
  
      ray.shutdown()
  
file_path: ClassyVision/classy_vision/distributed/launch_ray.py
imports: import logging
  import os
  import socket
  import subprocess
  import sys
  import time
  from argparse import ArgumentParser, REMAINDER
  from contextlib import closing
  import ray
label_desc: Use image node_id 3 for calling a global function with example usage: main() without return types