src/transformers/models/flaubert/tokenization_flaubert.py/convert_to_unicode
def convert_to_unicode(text):
    """
    Converts `text` to Unicode (if it's not already), assuming UTF-8 input.
    """
    # six_ensure_text is copied from https://github.com/benjaminp/six
    def six_ensure_text(s, encoding="utf-8", errors="strict"):
        if isinstance(s, six.binary_type):
            return s.decode(encoding, errors)
        elif isinstance(s, six.text_type):
            return s
        else:
            raise TypeError(f"not expecting type '{type(s)}'")

    return six_ensure_text(text, encoding="utf-8", errors="ignore")