code: def write(
          self, filepath, fully_qualified=True, pretty_print=False, encoding="UTF-8"
      ):
          
          root = self.serialize(fully_qualified=fully_qualified)
          tree = root.getroottree()
          kwargs = {"pretty_print": pretty_print, "encoding": encoding}
          if encoding != "unicode":
              kwargs["xml_declaration"] = True
          tree.write(filepath, **kwargs)
docs: Serialize and write this METS document to `filepath`.
  
          The default encoding is ``UTF-8``. This method will return a unicode
          string when ``encoding`` is set to ``unicode``.
  
          :param str filepath: Path to write the METS document to