def METHOD_NAME(func, args, nprocs, master_addr="localhost", master_port=None):
    """Launch processes with a given function and given arguments.
    .. note:: Current implementaiton supports only single node case.
    """
    if master_port is None:
        master_port = free_port()
    # Set PyTorch distributed related environmental variables
    # NOTE: in contrast to subprocess.Popen,
    # explicit environment variables can not be specified.
    # It's necessary to add additional variables to
    # current environment variable list.
    original_env = os.environ.copy()
    # TODO(lazykyama): multi-node support
    os.environ["WORLD_SIZE"] = str(nprocs)
    os.environ["MASTER_ADDR"] = master_addr
    os.environ["MASTER_PORT"] = str(master_port)
    processes = []
    for local_rank in range(nprocs):
        # Each process's rank
        # TODO(lazykyama): multi-node support
        os.environ["RANK"] = str(local_rank)
        os.environ["LOCAL_RANK"] = str(local_rank)
        process = multiprocessing.Process(target=func, args=(args,))
        process.start()
        processes.append(process)
    # Set signal handler to capture signals sent to main process,
    # and ensure that all children processes will be terminated.
    def _handler(signal_no, _):
        _kill_processes(processes)
        raise MainProcessError(signal_no=signal_no)
    signal.signal(signal.SIGINT, _handler)
    signal.signal(signal.SIGTERM, _handler)
    # Recovery environment variables.
    os.environ.clear()
    os.environ.update(original_env)
    # Monitor all workers.
    worker_error = None
    finished_process_ids = set()
    while len(processes) > len(finished_process_ids):
        for localrank, p in enumerate(processes):
            if p.pid in finished_process_ids:
                # Skip rest of checks becuase
                # this process has been already finished.
                continue
            if p.is_alive():
                # This process is still running.
                continue
            elif p.exitcode == 0:
                # This process properly finished.
                finished_process_ids.add(p.pid)
            else:
                # An error happens in one process.
                # Will try to terminate all other processes.
                worker_error = WorkerError(
                    msg=(f"{func.__name__} failed with error code: {p.exitcode}"),
                    exitcode=p.exitcode,
                    worker_id=localrank,
                )
                break
        if worker_error is not None:
            # Go out of this while loop to terminate all processes.
            break
        time.sleep(1.0)
    if worker_error is not None:
        # Trying to stop all workers.
        _kill_processes(processes)
        raise worker_error