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: Construct the `EventAccumulator`.
  
  Args:
    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.
    size_guidance: Information on how much data the EventAccumulator should
      store in memory. The DEFAULT_SIZE_GUIDANCE tries not to store too much
      so as to avoid OOMing the client. The size_guidance should be a map
      from a `tagType` string to an integer representing the number of
      items to keep per tag for items of that `tagType`. If the size is 0,
      all events are stored.
    tensor_size_guidance: Like `size_guidance`, but allowing finer
      granularity for tensor summaries. Should be a map from the
      `plugin_name` field on the `PluginData` proto to an integer
      representing the number of items to keep per tag. Plugins for
      which there is no entry in this map will default to the value of
      `size_guidance[event_accumulator.TENSORS]`. Defaults to `{}`.
    purge_orphaned_data: Whether to discard any events that were "orphaned" by
      a TensorFlow restart.
    event_file_active_filter: Optional predicate for determining whether an
      event file latest load timestamp should be considered active. If passed,
      this will enable multifile directory loading.
    detect_file_replacement: Optional boolean; if True, event file loading
      will try to detect when a file has been replaced with a new version
      that contains additional data, by monitoring the file size.
docstr_tok: ["Construct","the","`","EventAccumulator","`",".","Args",":","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",".","size_guidance",":","Information","on","how","much","data","the","EventAccumulator","should","store","in","memory",".","The","DEFAULT_SIZE_GUIDANCE","tries","not","to","store","too","much","so","as","to","avoid","OOMing","the","client",".","The","size_guidance","should","be","a","map","from","a","`","tagType","`","string","to","an","integer","representing","the","number","of","items","to","keep","per","tag","for","items","of","that","`","tagType","`",".","If","the","size","is","0",",","all","events","are","stored",".","tensor_size_guidance",":","Like","`","size_guidance","`",",","but","allowing","finer","granularity","for","tensor","summaries",".","Should","be","a","map","from","the","`","plugin_name","`","field","on","the","`","PluginData","`","proto","to","an","integer","representing","the","number","of","items","to","keep","per","tag",".","Plugins","for","which","there","is","no","entry","in","this","map","will","default","to","the","value","of","`","size_guidance","[","event_accumulator.TENSORS","]","`",".","Defaults","to","`","{","}","`",".","purge_orphaned_data",":","Whether","to","discard","any","events","that","were","``","orphaned","''","by","a","TensorFlow","restart",".","event_file_active_filter",":","Optional","predicate","for","determining","whether","an","event","file","latest","load","timestamp","should","be","considered","active",".","If","passed",",","this","will","enable","multifile","directory","loading",".","detect_file_replacement",":","Optional","boolean",";","if","True",",","event","file","loading","will","try","to","detect","when","a","file","has","been","replaced","with","a","new","version","that","contains","additional","data",",","by","monitoring","the","file","size","."]
code: def __init__(
      self,
      path,
      size_guidance=None,
      tensor_size_guidance=None,
      purge_orphaned_data=True,
      event_file_active_filter=None,
      detect_file_replacement=None,
  ):
      """Construct the `EventAccumulator`.
  
      Args:
        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.
        size_guidance: Information on how much data the EventAccumulator should
          store in memory. The DEFAULT_SIZE_GUIDANCE tries not to store too much
          so as to avoid OOMing the client. The size_guidance should be a map
          from a `tagType` string to an integer representing the number of
          items to keep per tag for items of that `tagType`. If the size is 0,
          all events are stored.
        tensor_size_guidance: Like `size_guidance`, but allowing finer
          granularity for tensor summaries. Should be a map from the
          `plugin_name` field on the `PluginData` proto to an integer
          representing the number of items to keep per tag. Plugins for
          which there is no entry in this map will default to the value of
          `size_guidance[event_accumulator.TENSORS]`. Defaults to `{}`.
        purge_orphaned_data: Whether to discard any events that were "orphaned" by
          a TensorFlow restart.
        event_file_active_filter: Optional predicate for determining whether an
          event file latest load timestamp should be considered active. If passed,
          this will enable multifile directory loading.
        detect_file_replacement: Optional boolean; if True, event file loading
          will try to detect when a file has been replaced with a new version
          that contains additional data, by monitoring the file size.
      """
      size_guidance = dict(size_guidance or DEFAULT_SIZE_GUIDANCE)
      sizes = {}
      for key in DEFAULT_SIZE_GUIDANCE:
          if key in size_guidance:
              sizes[key] = size_guidance[key]
          else:
              sizes[key] = DEFAULT_SIZE_GUIDANCE[key]
      self._size_guidance = size_guidance
      self._tensor_size_guidance = dict(tensor_size_guidance or {})
  
      self._first_event_timestamp = None
  
      self._graph = None
      self._graph_from_metagraph = False
      self._meta_graph = None
      self._tagged_metadata = {}
      self.summary_metadata = {}
      self.tensors_by_tag = {}
      self._tensors_by_tag_lock = threading.Lock()
  
      # Keep a mapping from plugin name to a dict mapping from tag to plugin data
      # content obtained from the SummaryMetadata (metadata field of Value) for
      # that plugin (This is not the entire SummaryMetadata proto - only the
      # content for that plugin). The SummaryWriter only keeps the content on the
      # first event encountered per tag, so we must store that first instance of
      # content for each tag.
      self._plugin_to_tag_to_content = collections.defaultdict(dict)
      # Locks the dict `_plugin_to_tag_to_content` as well as the
      # dicts `_plugin_to_tag_to_content[p]` for each `p`.
      self._plugin_tag_lock = threading.Lock()
  
      self.path = path
      self._generator = _GeneratorFromPath(
          path, event_file_active_filter, detect_file_replacement
      )
      self._generator_mutex = threading.Lock()
  
      self.purge_orphaned_data = purge_orphaned_data
      self._seen_session_start = False
  
      self.most_recent_step = -1
      self.most_recent_wall_time = -1
      self.file_version = None
  
      # Name of the source writer that writes the event.
      self._source_writer = None
  
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 1 to create a new EventAccumulator object  with example: obj = EventAccumulator(path, size_guidance, tensor_size_guidance, purge_orphaned_data, event_file_active_filter, detect_file_replacement)