              for loss_key, loss in all_loss[key].items():
                  loss_dict.setdefault(loss_key, []).extend(loss)
          return loss_dict
  
      @property
      def _total_loss_keys(self):
          """ list: The loss keys for all sessions. """
          loss_keys = set(loss_key
                          for session in self.state["sessions"].values()
                          for loss_key in session["loss_names"])
          return list(loss_keys)
  
      @property
      def total_timestamps(self):
          """ Return timestamps from logs separated per session for all sessions """
          return self.tb_logs.get_timestamps()
 
</s> remove     @property
    def total_loss(self):
        """ dict: The collated loss for all sessions for each loss key """
        loss_dict = dict()
        all_loss = self.tb_logs.get_loss()
        for key in sorted(all_loss):
            for loss_key, loss in all_loss[key].items():
                loss_dict.setdefault(loss_key, []).extend(loss)
        return loss_dict
 </s> add             self._time_stats = {
                sess_id: dict(start_time=np.min(timestamps) if np.any(timestamps) else 0,
                              end_time=np.max(timestamps) if np.any(timestamps) else 0,
                              iterations=timestamps.shape[0] if np.any(timestamps) else 0)
                for sess_id, timestamps in self._session.get_timestamps(None).items()} </s> remove     @property
    def total_timestamps(self):
        """ Return timestamps from logs separated per session for all sessions """
        return self.tb_logs.get_timestamps()

    def initialize_session(self, is_training=False, session_id=None):
        """ Initialize the training session """
        logger.debug("Initializing session: (is_training: %s, session_id: %s)",
                     is_training, session_id)
        self.load_state_file()
        self.tb_logs = TensorBoardLogs(os.path.join(self.modeldir,
                                                    "{}_logs".format(self.modelname)))
        if is_training:
            self.session_id = max(int(key) for key in self.state["sessions"].keys())
        else:
            self.session_id = session_id
        self.initialized = True
        logger.debug("Initialized session. Session_ID: %s", self.session_id)
 </s> add             session_id = Session.session_ids[-1]
            latest = self._session.get_timestamps(session_id) </s> remove     @property
    def loss_keys(self):
        """ list: The loss keys for the current session, or loss keys for all sessions. """
        if self.session_id is None:
            retval = self._total_loss_keys
        else:
            retval = self.session["loss_names"]
        return retval
 </s> add     Parameters
    ----------
    session: :class:`GlobalSession`
        The loaded or currently training session
    """
    def __init__(self, session):
        logger.debug("Initializing %s: (session: %s)", self.__class__.__name__, session)
        self._session = session
        self._state = session._state </s> remove     @property
    def loss(self):
        """ dict: The loss for the current session id for each loss key """
        loss_dict = self.tb_logs.get_loss(session=self.session_id)[self.session_id]
        return loss_dict
 </s> add class SessionsSummary():  # pylint:disable=too-few-public-methods
    """ Performs top level summary calculations for each session ID within the loaded or currently
    training Session for display in the Analysis tree view. </s> remove     @property
    def total_iterations(self):
        """ Return session iterations """
        return self.state["iterations"]
 </s> add         If the main Session is currently training, then the training session ID is updated with the
        latest stats.
        """
        if self._time_stats is None:
            logger.debug("Collating summary time stamps")
        elif Session.is_training:
            logger.debug("Updating summary time stamps for training session")
              for loss_key, loss in all_loss[key].items():
                  loss_dict.setdefault(loss_key, []).extend(loss)
          return loss_dict
  
        elif Session.is_training:
            logger.debug("Updating summary time stamps for training session")
        elif Session.is_training:
            logger.debug("Updating summary time stamps for training session")
        elif Session.is_training:
            logger.debug("Updating summary time stamps for training session")
        elif Session.is_training:
            logger.debug("Updating summary time stamps for training session")
        elif Session.is_training:
            logger.debug("Updating summary time stamps for training session")
        elif Session.is_training:
            logger.debug("Updating summary time stamps for training session")
        elif Session.is_training:
            logger.debug("Updating summary time stamps for training session")
  
      @property
      def total_timestamps(self):
          """ Return timestamps from logs separated per session for all sessions """
          return self.tb_logs.get_timestamps()
keep keep keep keep replace replace replace replace 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/stats.py