human
Complete the below
def _clean_tags(tags):

    ''''Helper method that does the actual cleaning of tags for sending to statsd.
    1. Handles any type of tag - a plain string, UTF-8 binary, or a unicode
    string, and converts it to UTF-8 encoded bytestring needed by statsd.
    2. Escape pipe character - used by statsd as a field separator.
    3. Trim to 200 characters (DataDog API limitation)'
    '''

=====
Write me a the Python code you requested?
assistant
#Here is the Python code you requested.
    def clean(tagstr):
        if isinstance(tagstr, str):
            return tagstr.replace('|', '_')[:200]
        return unicode(tagstr).replace('|', '_')[:200].encode('utf-8')
    return [clean(t) for t in tags]