                  logger.debug("GUI Trigger received for: '%s'", trigger)
  
                  logger.debug("Removing gui trigger file: %s", filename)
                  os.remove(filename)
                  if trigger == "update":
                      print("\n")  # Let log print on different line from loss output
                      logger.info("Refresh preview requested...")
                  getattr(self._preview, parent_flags[trigger])()
  
      def _monitor(self, thread: MultiThread) -> bool:
          """ Monitor the background :func:`_training` thread for key presses and errors.
 
</s> remove                 getattr(self._preview, parent_flags[trigger])()
 </s> add         return retval </s> remove 
 </s> add                 retval[trigger] = True </s> remove         parent_flags = dict(mask_toggle="request_mask_toggle", update="request_refresh")
        for trigger in ("mask_toggle", "update"):
            filename = self._gui_triggers[trigger]
 </s> add         for trigger, filename in self._gui_triggers.items(): </s> remove         Parameters
        ----------
        event:
            The key press received
        """
        key = event.key.lower()
        if key not in self._callbacks:
 </s> add     def shutdown(self) -> None:
        """ Send a signal to shutdown the preview window. """
        if not self._active: </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()
                if trigger == "refresh":
                    print("")  # Let log print on different line from loss output
                  logger.debug("GUI Trigger received for: '%s'", trigger)
  
                  logger.debug("Removing gui trigger file: %s", filename)
                  os.remove(filename)
                if trigger == "refresh":
                    print("")  # Let log print on different line from loss output
                if trigger == "refresh":
                    print("")  # Let log print on different line from loss output
                      logger.info("Refresh preview requested...")
                  getattr(self._preview, parent_flags[trigger])()
  
      def _monitor(self, thread: MultiThread) -> bool:
          """ Monitor the background :func:`_training` thread for key presses and errors.
keep keep keep keep replace replace keep keep keep keep keep
 Training - Use custom preview pop-out 
scripts/train.py