<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ensure_unicode_string(obj):
 """ Return a unicode string representation of the given obj. :param obj: The obj we want to represent in unicode :type obj: varies :rtype: `unicode` """

    try:
        return unicode_type(obj)
    except UnicodeDecodeError:
        if hasattr(obj, 'decode'):
            return obj.decode('utf-8', 'replace')
        return str(obj).decode('utf-8', 'replace')