class_docstr: An `EventAccumulator` takes an event generator, and accumulates the
  values.
  
  The `EventAccumulator` is intended to provide a convenient Python
  interface for loading Event data written during a TensorFlow run.
  TensorFlow writes out `Event` protobuf objects, which have a timestamp
  and step number, and often contain a `Summary`. Summaries can have
  different kinds of data stored as arbitrary tensors. The Summaries
  also have a tag, which we use to organize logically related data. The
  `EventAccumulator` supports retrieving the `Event` and `Summary` data
  by its tag.
  
  Calling `Tags()` gets a map from `tagType` (i.e., `tensors`) to the
  associated tags for those data types. Then, the functional endpoint
  (i.g., `Accumulator.Tensors(tag)`) allows for the retrieval of all
  data associated with that tag.
  
  The `Reload()` method synchronously loads all of the data written so far.
  
  Fields:
    most_recent_step: Step of last Event proto added. This should only
        be accessed from the thread that calls Reload. This is -1 if
        nothing has been loaded yet.
    most_recent_wall_time: Timestamp of last Event proto added. This is
        a float containing seconds from the UNIX epoch, or -1 if
        nothing has been loaded yet. This should only be accessed from
        the thread that calls Reload.
    path: A file path to a directory containing tf events files, or a single
        tf events file. The accumulator will load events from this path.
    tensors_by_tag: A dictionary mapping each tag name to a
      reservoir.Reservoir of tensor summaries. Each such reservoir will
      only use a single key, given by `_TENSOR_RESERVOIR_KEY`.
  
  @@Tensors
class_docstr_tok: ["An","`","EventAccumulator","`","takes","an","event","generator",",","and","accumulates","the","values",".","The","`","EventAccumulator","`","is","intended","to","provide","a","convenient","Python","interface","for","loading","Event","data","written","during","a","TensorFlow","run",".","TensorFlow","writes","out","`","Event","`","protobuf","objects",",","which","have","a","timestamp","and","step","number",",","and","often","contain","a","`","Summary","`",".","Summaries","can","have","different","kinds","of","data","stored","as","arbitrary","tensors",".","The","Summaries","also","have","a","tag",",","which","we","use","to","organize","logically","related","data",".","The","`","EventAccumulator","`","supports","retrieving","the","`","Event","`","and","`","Summary","`","data","by","its","tag",".","Calling","`","Tags","(",")","`","gets","a","map","from","`","tagType","`","(","i.e.",",","`","tensors","`",")","to","the","associated","tags","for","those","data","types",".","Then",",","the","functional","endpoint","(","i.g.",",","`","Accumulator.Tensors","(","tag",")","`",")","allows","for","the","retrieval","of","all","data","associated","with","that","tag",".","The","`","Reload","(",")","`","method","synchronously","loads","all","of","the","data","written","so","far",".","Fields",":","most_recent_step",":","Step","of","last","Event","proto","added",".","This","should","only","be","accessed","from","the","thread","that","calls","Reload",".","This","is","-1","if","nothing","has","been","loaded","yet",".","most_recent_wall_time",":","Timestamp","of","last","Event","proto","added",".","This","is","a","float","containing","seconds","from","the","UNIX","epoch",",","or","-1","if","nothing","has","been","loaded","yet",".","This","should","only","be","accessed","from","the","thread","that","calls","Reload",".","path",":","A","file","path","to","a","directory","containing","tf","events","files",",","or","a","single","tf","events","file",".","The","accumulator","will","load","events","from","this","path",".","tensors_by_tag",":","A","dictionary","mapping","each","tag","name","to","a","reservoir.Reservoir","of","tensor","summaries",".","Each","such","reservoir","will","only","use","a","single","key",",","given","by","`","_TENSOR_RESERVOIR_KEY","`",".","@","@","Tensors"]
docstr: 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.
docstr_tok: ["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","."]
code: def _Purge(self, event, by_tags):
      """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.
      """
      ## Keep data in reservoirs that has a step less than event.step
      _NotExpired = lambda x: x.step < event.step
  
      num_expired = 0
      if by_tags:
          for value in event.summary.value:
              if value.tag in self.tensors_by_tag:
                  tag_reservoir = self.tensors_by_tag[value.tag]
                  num_expired += tag_reservoir.FilterItems(
                      _NotExpired, _TENSOR_RESERVOIR_KEY
                  )
      else:
          for tag_reservoir in self.tensors_by_tag.values():
              num_expired += tag_reservoir.FilterItems(
                  _NotExpired, _TENSOR_RESERVOIR_KEY
              )
      if num_expired > 0:
          purge_msg = _GetPurgeMessage(
              self.most_recent_step,
              self.most_recent_wall_time,
              event.step,
              event.wall_time,
              num_expired,
          )
          logger.warning(purge_msg)
  
imports: import collections
  import dataclasses
  import threading
  from typing import Optional
  from tensorboard.backend.event_processing import directory_loader
  from tensorboard.backend.event_processing import directory_watcher
  from tensorboard.backend.event_processing import event_file_loader
  from tensorboard.backend.event_processing import event_util
  from tensorboard.backend.event_processing import io_wrapper
  from tensorboard.backend.event_processing import plugin_asset_util
  from tensorboard.backend.event_processing import reservoir
  from tensorboard.backend.event_processing import tag_types
  from tensorboard.compat.proto import config_pb2
  from tensorboard.compat.proto import event_pb2
  from tensorboard.compat.proto import graph_pb2
  from tensorboard.compat.proto import meta_graph_pb2
  from tensorboard.compat.proto import tensor_pb2
  from tensorboard.util import tb_logging
label_desc: Use image node_id 23 for calling the EventAccumulator obj's underlying member method code with example usage: obj._Purge(event, by_tags) without return types