              if self.trace_var is None:
                  self.trace_var = smooth_amount_var.trace("w", self.smooth_amount_callback)
          else:
              self.display_item = None
              if self.trace_var is not None:
                  smooth_amount_var.trace_vdelete("w", self.trace_var)
                  self.trace_var = None
  
      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())
 
</s> remove             self.display_item = session
            if self.trace_var is None:
                self.trace_var = smooth_amount_var.trace("w", self.smooth_amount_callback)
 </s> add             self.display_item = Session
            self._add_trace_variables() </s> remove             if self.trace_var is not None:
                smooth_amount_var.trace_vdelete("w", self.trace_var)
                self.trace_var = None
        elif session.initialized:
 </s> add             self._clear_trace_variables()
        elif Session.is_training and self.display_item is None: </s> remove         session = get_config().session
        smooth_amount_var = get_config().tk_vars["smoothgraph"]
        if session.initialized and session.logging_disabled:
 </s> add         if Session.is_training and Session.logging_disabled: </s> remove         if self.trace_var is not None:
            get_config().tk_vars["smoothgraph"].trace_vdelete("w", self.trace_var)
            self.trace_var = None
 </s> add         self._clear_trace_variables()
            self._clear_trace_variables()
              if self.trace_var is None:
                  self.trace_var = smooth_amount_var.trace("w", self.smooth_amount_callback)
          else:
              self.display_item = None
            self._clear_trace_variables()
            self._clear_trace_variables()
            self._clear_trace_variables()
  
      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())
keep keep keep keep replace replace 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