          keypress = KBHit(is_gui=self._args.redirect_gui)
          err = False
          while True:
              try:
                  if self._args.preview:
                      self._preview.display_preview()
  
                  if thread.has_error:
                      logger.debug("Thread error detected")
                      err = True
                      break
                  if self._stop:
 
</s> remove                 if self._preview.should_quit():
 </s> add                 if self._preview.should_quit: </s> remove                 if self._preview.should_save():
 </s> add                 if self._preview.should_save: </s> remove 
        logger.debug("Preview window keypress '%s' received", key)
        if key == "r":
            print("\n")  # Let log print on different line from loss output
            logger.info("Refresh preview requested...")

        with self._lock:
            if key == "f":
                self._toggle_size()
            else:
                self._triggers[self._callbacks[key]] = True

    def _on_resize(self,
                   event: backend_bases.ResizeEvent) -> None:  # noqa # pylint:disable=unused-argument
        """ If the display is set to `actual size` then the image needs to be resized on any window
        resize event. """
        for fig, size in self._images.values():
            fig.set_size_inches(size)

    def _on_close(self,
                   event: backend_bases.CloseEvent) -> None:  # noqa # pylint:disable=unused-argument
        """ Force an update when the figure has been closed to relaunch it. """
        logger.debug("Preview close detected")
        with self._lock:
            self._needs_update = True
 </s> add         logger.debug("Sending shutdown to preview viewer")
        self._triggers["shutdown"].set()
          keypress = KBHit(is_gui=self._args.redirect_gui)
          err = False
          while True:
              try:



                  if thread.has_error:
                      logger.debug("Thread error detected")
                      err = True
                      break
                  if self._stop:
keep keep keep keep replace replace replace keep keep keep keep keep
 Training - Use custom preview pop-out 
scripts/train.py