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: Maybe purge orphaned data due to a TensorFlow crash.
  
  When TensorFlow crashes at step T+O and restarts at step T, any events
  written after step T are now "orphaned" and will be at best misleading if
  they are included in TensorBoard.
  
  This logic attempts to determine if there is orphaned data, and purge it
  if it is found.
  
  Args:
    event: The event to use as a reference, to determine if a purge is needed.
docstr_tok: ["Maybe","purge","orphaned","data","due","to","a","TensorFlow","crash",".","When","TensorFlow","crashes","at","step","T+O","and","restarts","at","step","T",",","any","events","written","after","step","T","are","now","``","orphaned","''","and","will","be","at","best","misleading","if","they","are","included","in","TensorBoard",".","This","logic","attempts","to","determine","if","there","is","orphaned","data",",","and","purge","it","if","it","is","found",".","Args",":","event",":","The","event","to","use","as","a","reference",",","to","determine","if","a","purge","is","needed","."]
code: def _MaybePurgeOrphanedData(self, event):
      """Maybe purge orphaned data due to a TensorFlow crash.
  
      When TensorFlow crashes at step T+O and restarts at step T, any events
      written after step T are now "orphaned" and will be at best misleading if
      they are included in TensorBoard.
  
      This logic attempts to determine if there is orphaned data, and purge it
      if it is found.
  
      Args:
        event: The event to use as a reference, to determine if a purge is needed.
      """
      if not self.purge_orphaned_data:
          return
      ## Check if the event happened after a crash, and purge expired tags.
      if self.file_version and self.file_version >= 2:
          ## If the file_version is recent enough, use the SessionLog enum
          ## to check for restarts.
          self._CheckForRestartAndMaybePurge(event)
      else:
          ## If there is no file version, default to old logic of checking for
          ## out of order steps.
          self._CheckForOutOfOrderStepAndMaybePurge(event)
      # After checking, update the most recent summary step and wall time.
      if event.HasField("summary"):
          self.most_recent_step = event.step
          self.most_recent_wall_time = event.wall_time
  
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 18 for calling the EventAccumulator obj's underlying member method code with example usage: obj._MaybePurgeOrphanedData(event) without return types