human
Complete this python program:
def amp(text):
assistant
#Here is the Python program you requested.

    """Wraps apersands in HTML with ``<span class="amp">`` so they can be
    styled with CSS. Apersands are also normalized to ``&amp;``. Requires
    ampersands to have whitespace or an ``&nbsp;`` on both sides.
    >>> amp(\One & two\)
    u\One <span class="amp">&amp;</span> two\
    >>> amp(\One &amp; two\)
    u\One <span class="amp">&amp;</span> two\
    >>> amp(\One &#38; two\)
    u\One <span class="amp">&amp;</span> two\
    >>> amp(\One&nbsp;&amp;&nbsp;two\)
    u\One&nbsp;<span class="amp">&amp;</span>&nbsp;two\
    It won\t mess up & that are already wrapped, in entities or URLs
    >>> amp(\One <span class="amp">&amp;</span> two\)
    u\One <span class="amp">&amp;</span> two\
    >>> amp(\&ldquo;this&rdquo; & <a href="/?that&amp;test">that</a>\)
    u\&ldquo;this&rdquo; <span class="amp">&amp;</span> <a href="/?that&amp;test">that</a>\
    It should ignore standalone amps that are in attributes
    >>> amp(\<link href="xyz.html" title="One & Two">xyz</link>\)
    u\<link href="xyz.html" title="One & Two">xyz</link>\
    """
    text = force_unicode(text)
    tag_pattern = '</?\\w+((\\s+\\w+(\\s*=\\s*(?:".*?"|\'.*?\'|[^\'">\\s]+))?)+\\s*|\\s*)/?>'
    amp_finder = re.compile('(\\s|&nbsp;)(&|&amp;|&\\#38;)(\\s|&nbsp;)')
    intra_tag_finder = re.compile(('(?P<prefix>(%s)?)(?P<text>([^<]*))(?P<suffix>(%s)?)' % (tag_pattern, tag_pattern)))
    def _amp_process(groups):
        prefix = (groups.group('prefix') or '')
        text = amp_finder.sub('\\1<span    class="amp">&amp;</span>\\3', groups.group('text'))
        suffix = (groups.group('suffix') or '')
        return ((prefix + text) + suffix)
    output = intra_tag_finder.sub(_amp_process, text)
    return mark_safe(output)