human
Complete the below
def launch_tor(tor_cmd='tor', args=None, torrc_path=None, completion_percent=100, init_msg_handler=None, timeout=DEFAULT_INIT_TIMEOUT, take_ownership=False, stdin=None):

    ''''Initializes a tor process. This blocks until initialization completes or we
    error out.
    If tor\'s data directory is missing or stale then bootstrapping will include
    making several requests to the directory authorities which can take a little
    while. Usually this is done in 50 seconds or so, but occasionally calls seem
    to get stuck, taking well over the default timeout.
    **To work to must log at NOTICE runlevel to stdout.** It does this by
    default, but if you have a \'Log\' entry in your torrc then you\'ll also need
    \'Log NOTICE stdout\'.
    Note: The timeout argument does not work on Windows, and relies on the global
    state of the signal module.
    :param str tor_cmd: command for starting tor
    :param list args: additional arguments for tor
    :param str torrc_path: location of the torrc for us to use
    :param int completion_percent: percent of bootstrap completion at which
    this\'ll return
    :param functor init_msg_handler: optional functor that will be provided with
    tor\'s initialization stdout as we get it
    :param int timeout: time after which the attempt to start tor is aborted, no
    timeouts are applied if **None**
    :param bool take_ownership: asserts ownership over the tor process so it
    aborts if this python process terminates or a :class:`~stem.control.Controller`
    we establish to it disconnects
    :param str stdin: content to provide on stdin
    :returns: **subprocess.Popen** instance for the tor subprocess
    :raises: **OSError** if we either fail to create the tor process or reached a
    timeout without success'
    '''

What is a the Python code you requested?
assistant
#Here is the Python code you requested.
    if stem.util.system.is_windows():
        timeout = None
    if (os.path.sep in tor_cmd):
        if os.path.isdir(tor_cmd):
            raise OSError(("'%s'    is    a    directory,    not    the    tor    executable" % tor_cmd))
        elif (not os.path.isfile(tor_cmd)):
            raise OSError(("'%s'    doesn't    exist" % tor_cmd))
    elif (not stem.util.system.is_available(tor_cmd)):
        raise OSError(("'%s'    isn't    available    on    your    system.    Maybe    it's    not    in    your    PATH?" % tor_cmd))
    if ((torrc_path not in (None, NO_TORRC)) and (not os.path.exists(torrc_path))):
        raise OSError(("torrc    doesn't    exist    (%s)" % torrc_path))
    (runtime_args, temp_file) = ([tor_cmd], None)
    if args:
        runtime_args += args
    if torrc_path:
        if (torrc_path == NO_TORRC):
            temp_file = tempfile.mkstemp(prefix='empty-torrc-', text=True)[1]
            runtime_args += ['-f', temp_file]
        else:
            runtime_args += ['-f', torrc_path]
    if take_ownership:
        runtime_args += ['__OwningControllerProcess', str(os.getpid())]
    tor_process = subprocess.Popen(runtime_args, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
    if stdin:
        tor_process.stdin.write(stem.util.str_tools._to_bytes(stdin))
        tor_process.stdin.close()
    if timeout:
        def timeout_handler(signum, frame):
            tor_process.kill()
            raise OSError(('reached    a    %i    second    timeout    without    success' % timeout))
        signal.signal(signal.SIGALRM, timeout_handler)
        signal.alarm(timeout)
    bootstrap_line = re.compile('Bootstrapped    ([0-9]+)%:    ')
    problem_line = re.compile('\\[(warn|err)\\]    (.*)$')
    last_problem = 'Timed    out'
    try:
        while True:
            init_line = tor_process.stdout.readline().decode('utf-8', 'replace').strip()
            if (not init_line):
                tor_process.kill()
                raise OSError(('Process    terminated:    %s'...