code: def fs_encode(path):
      
  
      path = _get_path(path)
      if path is None:
          raise TypeError("expected a valid path to encode")
      if isinstance(path, six.text_type):
          if six.PY2:
              return b"".join(
                  (
                      _byte(ord(c) - 0xDC00)
                      if 0xDC00 <= ord(c) <= 0xDCFF
                      else c.encode(_fs_encoding, _fs_encode_errors)
                  )
                  for c in path
              )
          return path.encode(_fs_encoding, _fs_encode_errors)
      return path
docs: Encode a filesystem path to the proper filesystem encoding
  
      :param Union[str, bytes] path: A string-like path
      :returns: A bytes-encoded filesystem path representation