<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_zip( src_fs, # type: FS file, # type: Union[Text, BinaryIO] compression=zipfile.ZIP_DEFLATED, # type: int encoding="utf-8", # type: Text walker=None, # type: Optional[Walker] ):
 """Write the contents of a filesystem to a zip file. Arguments: src_fs (~fs.base.FS):
 The source filesystem to compress. file (str or io.IOBase):
 Destination file, may be a file name or an open file object. compression (int):
 Compression to use (one of the constants defined in the `zipfile` module in the stdlib). Defaults to `zipfile.ZIP_DEFLATED`. encoding (str):
 The encoding to use for filenames. The default is ``"utf-8"``, use ``"CP437"`` if compatibility with WinZip is desired. walker (~fs.walk.Walker, optional):
 A `Walker` instance, or `None` to use default walker. You can use this to specify which files you want to compress. """

    _zip = zipfile.ZipFile(file, mode="w", compression=compression, allowZip64=True)
    walker = walker or Walker()
    with _zip:
        gen_walk = walker.info(src_fs, namespaces=["details", "stat", "access"])
        for path, info in gen_walk:
            # Zip names must be relative, directory names must end
            # with a slash.
            zip_name = relpath(path + "/" if info.is_dir else path)
            if not six.PY3:
                # Python2 expects bytes filenames
                zip_name = zip_name.encode(encoding, "replace")

            if info.has_namespace("stat"):
                # If the file has a stat namespace, get the
                # zip time directory from the stat structure
                st_mtime = info.get("stat", "st_mtime", None)
                _mtime = time.localtime(st_mtime)
                zip_time = _mtime[0:6]  # type: ZipTime
            else:
                # Otherwise, use the modified time from details
                # namespace.
                mt = info.modified or datetime.utcnow()
                zip_time = (mt.year, mt.month, mt.day, mt.hour, mt.minute, mt.second)

            # NOTE(@althonos): typeshed's `zipfile.py` on declares
            #     ZipInfo.__init__ for Python < 3 ?!
            zip_info = zipfile.ZipInfo(zip_name, zip_time)  # type: ignore

            try:
                if info.permissions is not None:
                    zip_info.external_attr = info.permissions.mode << 16
            except MissingInfoNamespace:
                pass

            if info.is_dir:
                zip_info.external_attr |= 0x10
                # This is how to record directories with zipfile
                _zip.writestr(zip_info, b"")
            else:
                # Get a syspath if possible
                try:
                    sys_path = src_fs.getsyspath(path)
                except NoSysPath:
                    # Write from bytes
                    _zip.writestr(zip_info, src_fs.readbytes(path))
                else:
                    # Write from a file which is (presumably)
                    # more memory efficient
                    _zip.write(sys_path, zip_name)