code: def _Purge(self, event, by_tags):
      
      ## Keep data in reservoirs that has a step less than event.step
      _NotExpired = lambda x: x.step < event.step
  
      if by_tags:
        def _ExpiredPerTag(value):
          return [getattr(self, x).FilterItems(_NotExpired, value.tag)
                  for x in self.accumulated_attrs]
  
        expired_per_tags = [_ExpiredPerTag(value)
                            for value in event.summary.value]
        expired_per_type = [sum(x) for x in zip(*expired_per_tags)]
      else:
        expired_per_type = [getattr(self, x).FilterItems(_NotExpired)
                            for x in self.accumulated_attrs]
  
      if sum(expired_per_type) > 0:
        purge_msg = _GetPurgeMessage(self.most_recent_step,
                                     self.most_recent_wall_time, event.step,
                                     event.wall_time, *expired_per_type)
        logger.warn(purge_msg)
docs: Purge all events that have occurred after the given event.step.
  
      If by_tags is True, purge all events that occurred after the given
      event.step, but only for the tags that the event has. Non-sequential
      event.steps suggest that a TensorFlow restart occurred, and we discard
      the out-of-order events to display a consistent view in TensorBoard.
  
      Discarding by tags is the safer method, when we are unsure whether a restart
      has occurred, given that threading in supervisor can cause events of
      different tags to arrive with unsynchronized step values.
  
      If by_tags is False, then purge all events with event.step greater than the
      given event.step. This can be used when we are certain that a TensorFlow
      restart has occurred and these events can be discarded.
  
      Args:
        event: The event to use as reference for the purge. All events with
          the same tags, but with a greater event.step will be purged.
        by_tags: Bool to dictate whether to discard all out-of-order events or
          only those that are associated with the given reference event.