human
Complete this python program:
def encode_rfc2822_address_header(header_text):
assistant
#Here is the Python code you requested.

    """If ``header_text`` contains non-ASCII characters,
    attempts to locate patterns of the form
    ``"Name" <address@domain>`` and replace the
    ``"Name"`` portion by the RFC2047-encoded
    version, preserving the address part untouched.
    """
    def encode_addr(addr):
        (name, email) = addr
        if (not try_coerce_ascii(name)):
            name = str(Header(name, 'utf-8'))
        return formataddr((name, email))
    addresses = getaddresses([ustr(header_text).encode('utf-8')])
    return COMMASPACE.join(map(encode_addr, addresses))