<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def filter_debug(stream, it):
 """ Read line chunks from it, either yielding them directly, or building up and logging individual lines if they look like SSH debug output. This contains the mess of dealing with both line-oriented input, and partial lines such as the password prompt. Yields `(line, partial)` tuples, where `line` is the line, `partial` is :data:`True` if no terminating newline character was present and no more data exists in the read buffer. Consuming code can use this to unreliably detect the presence of an interactive prompt. """

    # The `partial` test is unreliable, but is only problematic when verbosity
    # is enabled: it's possible for a combination of SSH banner, password
    # prompt, verbose output, timing and OS buffering specifics to create a
    # situation where an otherwise newline-terminated line appears to not be
    # terminated, due to a partial read(). If something is broken when
    # ssh_debug_level>0, this is the first place to look.
    state = 'start_of_line'
    buf = b('')
    for chunk in it:
        buf += chunk
        while buf:
            if state == 'start_of_line':
                if len(buf) < 8:
                    # short read near buffer limit, block awaiting at least 8
                    # bytes so we can discern a debug line, or the minimum
                    # interesting token from above or the bootstrap
                    # ('password', 'MITO000\n').
                    break
                elif any(buf.startswith(p) for p in DEBUG_PREFIXES):
                    state = 'in_debug'
                else:
                    state = 'in_plain'
            elif state == 'in_debug':
                if b('\n') not in buf:
                    break
                line, _, buf = bytes_partition(buf, b('\n'))
                LOG.debug('%s: %s', stream.name,
                          mitogen.core.to_text(line.rstrip()))
                state = 'start_of_line'
            elif state == 'in_plain':
                line, nl, buf = bytes_partition(buf, b('\n'))
                yield line + nl, not (nl or buf)
                if nl:
                    state = 'start_of_line'