human
Complete the below
def _encode_metadata(metadata):

    ''''UTF8 encode any unicode keys or values in given metadata dict.
    :param metadata: a dict'
    '''
 What is a the Python program you requested?
assistant
#Here is the Python program you requested.
    def encode_str(item):
        if isinstance(item, six.text_type):
            return item.encode('utf8')
        return item
    return dict(((encode_str(k), encode_str(v)) for (k, v) in metadata.items()))