def METHOD_NAME(rank, cfg):
  if cfg.num_devices > 1:
    # Set 'fork' multiprocessing start method for improved DataLoader performance
    # We must set it explicitly as spawned processes have the 'spawn' method set by default
    mp.set_start_method('fork', force=True)
    # Initialize the process group
    os.environ['MASTER_ADDR'] = 'localhost'
    os.environ['MASTER_PORT'] = '12355'
    dist.init_process_group(backend='nccl',
                            rank=rank, world_size=cfg.num_devices,
                            init_method='env://')
    # Set the global rank for this worker process
    global WORKER_RANK
    WORKER_RANK = rank
    # Running in distributed mode
    return True
  else:
    # This is the only worker, not running in distributed mode
    return False