class_docstr: An `EventMultiplexer` manages access to multiple `EventAccumulator`s.
  
  Each `EventAccumulator` is associated with a `run`, which is a self-contained
  TensorFlow execution. The `EventMultiplexer` provides methods for extracting
  information about events from multiple `run`s.
  
  Example usage for loading specific runs from files:
  
  ```python
  x = EventMultiplexer({'run1': 'path/to/run1', 'run2': 'path/to/run2'})
  x.Reload()
  ```
  
  Example usage for loading a directory where each subdirectory is a run
  
  ```python
  (eg:) /parent/directory/path/
        /parent/directory/path/run1/
        /parent/directory/path/run1/events.out.tfevents.1001
        /parent/directory/path/run1/events.out.tfevents.1002
  
        /parent/directory/path/run2/
        /parent/directory/path/run2/events.out.tfevents.9232
  
        /parent/directory/path/run3/
        /parent/directory/path/run3/events.out.tfevents.9232
  x = EventMultiplexer().AddRunsFromDirectory('/parent/directory/path')
  (which is equivalent to:)
  x = EventMultiplexer({'run1': '/parent/directory/path/run1', 'run2':...}
  ```
  
  If you would like to watch `/parent/directory/path`, wait for it to be created
    (if necessary) and then periodically pick up new runs, use
    `AutoloadingMultiplexer`
  @@Tensors
docstr: Constructor for the `EventMultiplexer`.
  
  Args:
    run_path_map: Dict `{run: path}` which specifies the
      name of a run, and the path to find the associated events. If it is
      None, then the EventMultiplexer initializes without any runs.
    size_guidance: A dictionary mapping from `tagType` to the number of items
      to store for each tag of that type. See
      `event_accumulator.EventAccumulator` for details.
    tensor_size_guidance: A dictionary mapping from `plugin_name` to
      the number of items to store for each tag of that type. See
      `event_accumulator.EventAccumulator` for details.
    purge_orphaned_data: Whether to discard any events that were "orphaned" by
      a TensorFlow restart.
    max_reload_threads: The max number of threads that TensorBoard can use
      to reload runs. Each thread reloads one run at a time. If not provided,
      reloads runs serially (one after another).
    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: ["Constructor","for","the","`","EventMultiplexer","`",".","Args",":","run_path_map",":","Dict","`","{","run",":","path","}","`","which","specifies","the","name","of","a","run",",","and","the","path","to","find","the","associated","events",".","If","it","is","None",",","then","the","EventMultiplexer","initializes","without","any","runs",".","size_guidance",":","A","dictionary","mapping","from","`","tagType","`","to","the","number","of","items","to","store","for","each","tag","of","that","type",".","See","`","event_accumulator.EventAccumulator","`","for","details",".","tensor_size_guidance",":","A","dictionary","mapping","from","`","plugin_name","`","to","the","number","of","items","to","store","for","each","tag","of","that","type",".","See","`","event_accumulator.EventAccumulator","`","for","details",".","purge_orphaned_data",":","Whether","to","discard","any","events","that","were","``","orphaned","''","by","a","TensorFlow","restart",".","max_reload_threads",":","The","max","number","of","threads","that","TensorBoard","can","use","to","reload","runs",".","Each","thread","reloads","one","run","at","a","time",".","If","not","provided",",","reloads","runs","serially","(","one","after","another",")",".","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,
      run_path_map=None,
      size_guidance=None,
      tensor_size_guidance=None,
      purge_orphaned_data=True,
      max_reload_threads=None,
      event_file_active_filter=None,
      detect_file_replacement=None,
  ):
      """Constructor for the `EventMultiplexer`.
  
      Args:
        run_path_map: Dict `{run: path}` which specifies the
          name of a run, and the path to find the associated events. If it is
          None, then the EventMultiplexer initializes without any runs.
        size_guidance: A dictionary mapping from `tagType` to the number of items
          to store for each tag of that type. See
          `event_accumulator.EventAccumulator` for details.
        tensor_size_guidance: A dictionary mapping from `plugin_name` to
          the number of items to store for each tag of that type. See
          `event_accumulator.EventAccumulator` for details.
        purge_orphaned_data: Whether to discard any events that were "orphaned" by
          a TensorFlow restart.
        max_reload_threads: The max number of threads that TensorBoard can use
          to reload runs. Each thread reloads one run at a time. If not provided,
          reloads runs serially (one after another).
        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.
      """
      logger.info("Event Multiplexer initializing.")
      self._accumulators_mutex = threading.Lock()
      self._accumulators = {}
      self._paths = {}
      self._reload_called = False
      self._size_guidance = (
          size_guidance or event_accumulator.DEFAULT_SIZE_GUIDANCE
      )
      self._tensor_size_guidance = tensor_size_guidance
      self.purge_orphaned_data = purge_orphaned_data
      self._max_reload_threads = max_reload_threads or 1
      self._event_file_active_filter = event_file_active_filter
      self._detect_file_replacement = detect_file_replacement
      if run_path_map is not None:
          logger.info(
              "Event Multplexer doing initialization load for %s",
              run_path_map,
          )
          for run, path in run_path_map.items():
              self.AddRun(path, run)
      logger.info("Event Multiplexer done initializing")
  
imports: import os
  import queue
  import threading
  from typing import Optional
  from tensorboard.backend.event_processing import directory_watcher
  from tensorboard.backend.event_processing import plugin_event_accumulator
  from tensorboard.backend.event_processing import io_wrapper
  from tensorboard.util import tb_logging
label_desc: Use image node_id 1 to create a new EventMultiplexer object  with example: obj = EventMultiplexer(run_path_map, size_guidance, tensor_size_guidance, purge_orphaned_data, max_reload_threads, event_file_active_filter, detect_file_replacement)