      is_predict: bool
          ``True`` if the model is being loaded for inference. ``False`` if the model is being loaded
          for training.
      """
      def __init__(self, plugin: "ModelBase", model_dir: str, is_predict: bool) -> None:
          self._plugin = plugin
          self._is_predict = is_predict
          self._model_dir = model_dir
          self._history: List[List[float]] = [[], []]  # Loss histories per save iteration
          self._backup = Backup(self._model_dir, self._plugin.name)
 
</s> remove     def save(self) -> None:
 </s> add     def save(self, is_exit: bool = False) -> None: </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:
    def __init__(self,
                 plugin: "ModelBase",
                 model_dir: str,
                 is_predict: bool,
                 save_optimizer: Literal["never", "always", "exit"]) -> None:
      is_predict: bool
          ``True`` if the model is being loaded for inference. ``False`` if the model is being loaded
          for training.
      """
    def __init__(self,
                 plugin: "ModelBase",
                 model_dir: str,
                 is_predict: bool,
                 save_optimizer: Literal["never", "always", "exit"]) -> None:
          self._plugin = plugin
          self._is_predict = is_predict
          self._model_dir = model_dir
          self._history: List[List[float]] = [[], []]  # Loss histories per save iteration
          self._backup = Backup(self._model_dir, self._plugin.name)
keep keep keep keep replace keep keep keep keep keep
 Training: Add setting option to save optimizer weights 
plugins/train/model/_base/io.py