              raise FaceswapError("Penalized Mask Loss has been selected but you have not chosen a "
                                  "Mask to use. Please select a mask or disable Penalized Mask "
                                  "Loss.")
  
          self._io = IO(self, model_dir, self._is_predict)
          self._check_multiple_models()
  
          self._state = State(model_dir,
                              self.name,
                              self._config_changeable_items,
 
</s> remove     def _preview_monitor(self, key_press):
 </s> add     def _do_preview(self, window_created: bool) -> bool:
        """" Display an image preview in a resizable window

        Parameters
        ----------
        window_created: bool
            ``True`` if a preview window has been created otherwise ``False``

        Returns
        -------
        bool
            ``True`` if a preview window has been created otherwise ``False``
        """
        with self._lock:
            for name, image in self._preview_buffer.items():
                if not window_created:
                    self._create_resizable_window(name, image.shape)
                cv2.imshow(name, image)  # pylint: disable=no-member
            window_created = bool(self._preview_buffer) if not window_created else window_created
        return window_created

    def _check_keypress(self, keypress: KBHit) -> bool:
        """ Check if a keypress has been detected.

        Parameters
        ----------
        keypress: :class:`lib.keypress.KBHit`
            The keypress monitor

        Returns
        -------
        bool
            ``True`` if an exit keypress has been detected otherwise ``False``
        """
        retval = False
        if keypress.kbhit():
            console_key = keypress.getch()
            if console_key in ("\n", "\r"):
                logger.debug("Exit requested")
                retval = True
            if console_key in ("s", "S"):
                logger.info("Save requested")
                self._save_now = True
        return retval

    def _preview_monitor(self, key_press: str) -> bool: </s> remove             logger.verbose("Toggle mask display requested")
 </s> add             logger.verbose("Toggle mask display requested")  # type:ignore </s> remove         self._plugin.model.save(self._filename, include_optimizer=False)
 </s> add         include_optimizer = self._save_optimizer == "always" or (self._save_optimizer == "exit"
                                                                 and is_exit)
        self._plugin.model.save(self._filename, include_optimizer=include_optimizer) </s> remove     def _process_gui_triggers(self):
 </s> add     def _process_gui_triggers(self) -> None:
        self._io = IO(self, model_dir, self._is_predict, self.config["save_optimizer"])
              raise FaceswapError("Penalized Mask Loss has been selected but you have not chosen a "
                                  "Mask to use. Please select a mask or disable Penalized Mask "
                                  "Loss.")
  
        self._io = IO(self, model_dir, self._is_predict, self.config["save_optimizer"])
          self._check_multiple_models()
  
          self._state = State(model_dir,
                              self.name,
                              self._config_changeable_items,
keep keep keep keep replace keep keep keep keep keep
 Training: Add setting option to save optimizer weights 
plugins/train/model/_base/model.py