          logger.debug("Built training graph")
  
      def refresh(self, *args):  # pylint: disable=unused-argument
          """ Read loss data and apply to graph """
          logger.debug("Updating plot")
          self.calcs.refresh()
          self.update_plot(initiate=False)
          self.plotcanvas.draw()
          get_config().tk_vars["refreshgraph"].set(False)
  
      def save_fig(self, location):
          """ Save the figure to file """
          logger.debug("Saving graph: '%s'", location)
          keys = sorted([key.replace("raw_", "") for key in self.calcs.stats.keys()
 
</s> remove         for btntype in ("reset", "clear", "save", "load"):
 </s> add         for btntype in ("clear", "save", "load"): </s> remove                    "save the models and quit (it can take up a couple of seconds "
                   "depending on your training speed). If you want to kill it now, "
                   "press Ctrl + c")
 </s> add                    "save the models and quit (This can take a couple of minutes "
                   "depending on your training speed).")
            if not self.args.redirect_gui:
                msg += " If you want to kill it now, press Ctrl + c"
        refresh_var = get_config().tk_vars["refreshgraph"]
        if not refresh_var.get() and self.thread is None:
            return

        if self.thread is None:
            logger.debug("Updating plot data")
            self.thread = LongRunningTask(target=self.calcs.refresh)
            self.thread.start()
            self.after(1000, self.refresh)
        elif not self.thread.complete.is_set():
            logger.debug("Graph Data not yet available")
            self.after(1000, self.refresh)
        else:
            logger.debug("Updating plot with data from background thread")
            self.calcs = self.thread.get_result()  # Terminate the LongRunningTask object
            self.thread = None
            self.update_plot(initiate=False)
            self.plotcanvas.draw()
            refresh_var.set(False)
          logger.debug("Built training graph")
  
      def refresh(self, *args):  # pylint: disable=unused-argument
          """ Read loss data and apply to graph """
        refresh_var = get_config().tk_vars["refreshgraph"]
        if not refresh_var.get() and self.thread is None:
            return

        if self.thread is None:
            logger.debug("Updating plot data")
            self.thread = LongRunningTask(target=self.calcs.refresh)
            self.thread.start()
            self.after(1000, self.refresh)
        elif not self.thread.complete.is_set():
            logger.debug("Graph Data not yet available")
            self.after(1000, self.refresh)
        else:
            logger.debug("Updating plot with data from background thread")
            self.calcs = self.thread.get_result()  # Terminate the LongRunningTask object
            self.thread = None
            self.update_plot(initiate=False)
            self.plotcanvas.draw()
            refresh_var.set(False)
        refresh_var = get_config().tk_vars["refreshgraph"]
        if not refresh_var.get() and self.thread is None:
            return

        if self.thread is None:
            logger.debug("Updating plot data")
            self.thread = LongRunningTask(target=self.calcs.refresh)
            self.thread.start()
            self.after(1000, self.refresh)
        elif not self.thread.complete.is_set():
            logger.debug("Graph Data not yet available")
            self.after(1000, self.refresh)
        else:
            logger.debug("Updating plot with data from background thread")
            self.calcs = self.thread.get_result()  # Terminate the LongRunningTask object
            self.thread = None
            self.update_plot(initiate=False)
            self.plotcanvas.draw()
            refresh_var.set(False)
        refresh_var = get_config().tk_vars["refreshgraph"]
        if not refresh_var.get() and self.thread is None:
            return

        if self.thread is None:
            logger.debug("Updating plot data")
            self.thread = LongRunningTask(target=self.calcs.refresh)
            self.thread.start()
            self.after(1000, self.refresh)
        elif not self.thread.complete.is_set():
            logger.debug("Graph Data not yet available")
            self.after(1000, self.refresh)
        else:
            logger.debug("Updating plot with data from background thread")
            self.calcs = self.thread.get_result()  # Terminate the LongRunningTask object
            self.thread = None
            self.update_plot(initiate=False)
            self.plotcanvas.draw()
            refresh_var.set(False)
        refresh_var = get_config().tk_vars["refreshgraph"]
        if not refresh_var.get() and self.thread is None:
            return

        if self.thread is None:
            logger.debug("Updating plot data")
            self.thread = LongRunningTask(target=self.calcs.refresh)
            self.thread.start()
            self.after(1000, self.refresh)
        elif not self.thread.complete.is_set():
            logger.debug("Graph Data not yet available")
            self.after(1000, self.refresh)
        else:
            logger.debug("Updating plot with data from background thread")
            self.calcs = self.thread.get_result()  # Terminate the LongRunningTask object
            self.thread = None
            self.update_plot(initiate=False)
            self.plotcanvas.draw()
            refresh_var.set(False)
        refresh_var = get_config().tk_vars["refreshgraph"]
        if not refresh_var.get() and self.thread is None:
            return

        if self.thread is None:
            logger.debug("Updating plot data")
            self.thread = LongRunningTask(target=self.calcs.refresh)
            self.thread.start()
            self.after(1000, self.refresh)
        elif not self.thread.complete.is_set():
            logger.debug("Graph Data not yet available")
            self.after(1000, self.refresh)
        else:
            logger.debug("Updating plot with data from background thread")
            self.calcs = self.thread.get_result()  # Terminate the LongRunningTask object
            self.thread = None
            self.update_plot(initiate=False)
            self.plotcanvas.draw()
            refresh_var.set(False)
  
      def save_fig(self, location):
          """ Save the figure to file """
          logger.debug("Saving graph: '%s'", location)
          keys = sorted([key.replace("raw_", "") for key in self.calcs.stats.keys()
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
 GUI responsiveness and feature updates

- Add error handling to LongRunningTask
- Analysis: Fix timestats bug for missing session data
- Training: Update training graph inside LongRunningTask
- Training: Smoothing Amount Slider geometry fix
- Training: Auto update Analysis tab on training start and save interval
- Scripts: Keep control of the UI when terminating by terminating using LongRunningTask 
lib/gui/display_graph.py