      def display_item_process(self):
          """ Add a single graph to the graph window """
          logger.debug("Adding graph")
          existing = list(self.subnotebook_get_titles_ids().keys())
          loss_keys = [key for key in self.display_item.loss_keys if key != "total"]
          display_tabs = sorted(set(key[:-1].rstrip("_") for key in loss_keys))
          for loss_key in display_tabs:
              tabname = loss_key.replace("_", " ").title()
              if tabname in existing:
                  continue
 
</s> remove             if self.trace_var is not None:
                smooth_amount_var.trace_vdelete("w", self.trace_var)
                self.trace_var = None
 </s> add             self._clear_trace_variables() </s> remove             data = Calculations(session=get_config().session,
 </s> add             data = Calculations(session_id=Session.session_ids[-1], </s> remove             method = getattr(self, "calc_{}".format(selection))
            raw_keys = [key for key in self.stats.keys() if key.startswith("raw_")]
 </s> add             method = getattr(self, "_calc_{}".format(selection))
            raw_keys = [key for key in self._stats if key.startswith("raw_")]
        loss_keys = [key
                     for key in self.display_item.get_loss_keys(Session.session_ids[-1])
                     if key != "total"]
      def display_item_process(self):
          """ Add a single graph to the graph window """
          logger.debug("Adding graph")
          existing = list(self.subnotebook_get_titles_ids().keys())
        loss_keys = [key
                     for key in self.display_item.get_loss_keys(Session.session_ids[-1])
                     if key != "total"]
          display_tabs = sorted(set(key[:-1].rstrip("_") for key in loss_keys))
          for loss_key in display_tabs:
              tabname = loss_key.replace("_", " ").title()
              if tabname in existing:
                  continue
keep keep keep keep replace keep keep keep keep keep
 GUI - Stats optimization (#1067)

* Faster stat loading + caching

* Compress data in cache

* Optimize some calculations

* Vectorize smoothing

* stats.Calculations optimized

* Load latest training data from live iterator

* Add options to training graph 
lib/gui/display_command.py