code: def unescape_path(pth):
      
      if isinstance(pth, bytes):
          pth = pth.decode('utf-8')
      if sys.hexversion >= 0x03000000:
          if not isinstance(pth, str):
              raise TypeError('pth must be str or bytes.')
      else:
          if not isinstance(pth, unicode):
              raise TypeError('pth must be unicode or str.')
      # Look for invalid escapes.
      if _find_invalid_escape_re.search(pth) is not None:
          raise ValueError('Invalid escape found.')
      # Do all hex/unicode escapes.
      s = _find_escapes_re.sub(_replace_fun_unescape, pth)
      # Do all double backslash escapes.
      return s.replace(b'\\\\'.decode('ascii'), b'\\'.decode('ascii'))
docs: Hex/unicode unescapes a path.
  
      Unescapes a path. Valid escapeds are ``'\\xYY'``, ``'\\uYYYY', or
      ``'\\UYYYYYYYY'`` where Y are hex digits giving the character's
      unicode numerical value and double backslashes which are the escape
      for single backslashes.
  
      .. versionadded:: 0.2
  
      Parameters
      ----------
      pth : str
          The path to unescape.
  
      Returns
      -------
      unpth : str
          The unescaped path.
  
      Raises
      ------
      TypeError
          If `pth` is not the right type.
      ValueError
          If an invalid escape is found.
  
      See Also
      --------
      escape_path