class_docstr: Hook to print out examples per second.
  
  Total time is tracked and then divided by the total number of steps
  to get the average step time and then batch_size is used to determine
  the running average of examples per second. The examples per second for the
  most recent interval is also logged.
docstr: Initializer for ExamplesPerSecondHook.
  
  Args:
    batch_size: Total batch size across all workers used to calculate
      examples/second from global time.
    every_n_steps: Log stats every n steps.
    every_n_secs: Log stats every n seconds. Exactly one of the
      `every_n_steps` or `every_n_secs` should be set.
    warm_steps: The number of steps to be skipped before logging and running
      average calculation. warm_steps steps refers to global steps across all
      workers, not on each worker
    metric_logger: instance of `BenchmarkLogger`, the benchmark logger that
        hook should use to write the log. If None, BaseBenchmarkLogger will
        be used.
  
  Raises:
    ValueError: if neither `every_n_steps` or `every_n_secs` is set, or
    both are set.
docstr_tok: ["Initializer","for","ExamplesPerSecondHook",".","Args",":","batch_size",":","Total","batch","size","across","all","workers","used","to","calculate","examples\/second","from","global","time",".","every_n_steps",":","Log","stats","every","n","steps",".","every_n_secs",":","Log","stats","every","n","seconds",".","Exactly","one","of","the","`","every_n_steps","`","or","`","every_n_secs","`","should","be","set",".","warm_steps",":","The","number","of","steps","to","be","skipped","before","logging","and","running","average","calculation",".","warm_steps","steps","refers","to","global","steps","across","all","workers",",","not","on","each","worker","metric_logger",":","instance","of","`","BenchmarkLogger","`",",","the","benchmark","logger","that","hook","should","use","to","write","the","log",".","If","None",",","BaseBenchmarkLogger","will","be","used",".","Raises",":","ValueError",":","if","neither","`","every_n_steps","`","or","`","every_n_secs","`","is","set",",","or","both","are","set","."]
code: def __init__(
      self,
      batch_size,
      every_n_steps=None,
      every_n_secs=None,
      warm_steps=0,
      metric_logger=None,
  ):
      """Initializer for ExamplesPerSecondHook.
  
      Args:
        batch_size: Total batch size across all workers used to calculate
          examples/second from global time.
        every_n_steps: Log stats every n steps.
        every_n_secs: Log stats every n seconds. Exactly one of the
          `every_n_steps` or `every_n_secs` should be set.
        warm_steps: The number of steps to be skipped before logging and running
          average calculation. warm_steps steps refers to global steps across all
          workers, not on each worker
        metric_logger: instance of `BenchmarkLogger`, the benchmark logger that
            hook should use to write the log. If None, BaseBenchmarkLogger will
            be used.
  
      Raises:
        ValueError: if neither `every_n_steps` or `every_n_secs` is set, or
        both are set.
      """
  
      if (every_n_steps is None) == (every_n_secs is None):
          raise ValueError(
              "exactly one of every_n_steps"
              " and every_n_secs should be provided."
          )
  
      self._logger = metric_logger or logger.BaseBenchmarkLogger()
  
      self._timer = tf.estimator.SecondOrStepTimer(
          every_steps=every_n_steps, every_secs=every_n_secs
      )
  
      self._step_train_time = 0
      self._total_steps = 0
      self._batch_size = batch_size
      self._warm_steps = warm_steps
      # List of examples per second logged every_n_steps.
      self.current_examples_per_sec_list = []
  
file_path: autodist/examples/benchmark/utils/logs/hooks.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from utils.logs import logger
label_desc: Use image node_id 1 to create a new ExamplesPerSecondHook object from inherited base classes: tf.estimator with example: obj = ExamplesPerSecondHook(batch_size, every_n_steps, every_n_secs, warm_steps, metric_logger)