class_docstr: Hook to log benchmark metric information.
  
  This hook is very similar as tf.train.LoggingTensorHook, which logs given
  tensors every N local steps, every N seconds, or at the end. The metric
  information will be logged to given log_dir or via metric_logger in JSON
  format, which can be consumed by data analysis pipeline later.
  
  Note that if `at_end` is True, `tensors` should not include any tensor
  whose evaluation produces a side effect such as consuming additional inputs.
docstr: Initializer for LoggingMetricHook.
  
  Args:
    tensors: `dict` that maps string-valued tags to tensors/tensor names,
        or `iterable` of tensors/tensor names.
    metric_logger: instance of `BenchmarkLogger`, the benchmark logger that
        hook should use to write the log.
    every_n_iter: `int`, print the values of `tensors` once every N local
        steps taken on the current worker.
    every_n_secs: `int` or `float`, print the values of `tensors` once every N
        seconds. Exactly one of `every_n_iter` and `every_n_secs` should be
        provided.
    at_end: `bool` specifying whether to print the values of `tensors` at the
        end of the run.
  
  Raises:
    ValueError:
      1. `every_n_iter` is non-positive, or
      2. Exactly one of every_n_iter and every_n_secs should be provided.
      3. Exactly one of log_dir and metric_logger should be provided.
docstr_tok: ["Initializer","for","LoggingMetricHook",".","Args",":","tensors",":","`","dict","`","that","maps","string-valued","tags","to","tensors\/tensor","names",",","or","`","iterable","`","of","tensors\/tensor","names",".","metric_logger",":","instance","of","`","BenchmarkLogger","`",",","the","benchmark","logger","that","hook","should","use","to","write","the","log",".","every_n_iter",":","`","int","`",",","print","the","values","of","`","tensors","`","once","every","N","local","steps","taken","on","the","current","worker",".","every_n_secs",":","`","int","`","or","`","float","`",",","print","the","values","of","`","tensors","`","once","every","N","seconds",".","Exactly","one","of","`","every_n_iter","`","and","`","every_n_secs","`","should","be","provided",".","at_end",":","`","bool","`","specifying","whether","to","print","the","values","of","`","tensors","`","at","the","end","of","the","run",".","Raises",":","ValueError",":","1",".","`","every_n_iter","`","is","non-positive",",","or","2",".","Exactly","one","of","every_n_iter","and","every_n_secs","should","be","provided",".","3",".","Exactly","one","of","log_dir","and","metric_logger","should","be","provided","."]
code: def __init__(
      self,
      tensors,
      metric_logger=None,
      every_n_iter=None,
      every_n_secs=None,
      at_end=False,
  ):
      """Initializer for LoggingMetricHook.
  
      Args:
        tensors: `dict` that maps string-valued tags to tensors/tensor names,
            or `iterable` of tensors/tensor names.
        metric_logger: instance of `BenchmarkLogger`, the benchmark logger that
            hook should use to write the log.
        every_n_iter: `int`, print the values of `tensors` once every N local
            steps taken on the current worker.
        every_n_secs: `int` or `float`, print the values of `tensors` once every N
            seconds. Exactly one of `every_n_iter` and `every_n_secs` should be
            provided.
        at_end: `bool` specifying whether to print the values of `tensors` at the
            end of the run.
  
      Raises:
        ValueError:
          1. `every_n_iter` is non-positive, or
          2. Exactly one of every_n_iter and every_n_secs should be provided.
          3. Exactly one of log_dir and metric_logger should be provided.
      """
      super(LoggingMetricHook, self).__init__(
          tensors=tensors,
          every_n_iter=every_n_iter,
          every_n_secs=every_n_secs,
          at_end=at_end,
      )
  
      if metric_logger is None:
          raise ValueError("metric_logger should be provided.")
      self._logger = metric_logger
  
file_path: autodist/examples/benchmark/utils/logs/metric_hook.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
label_desc: Use image node_id 1 to create a new LoggingMetricHook object from inherited base classes: tf.estimator with example: obj = LoggingMetricHook(tensors, metric_logger, every_n_iter, every_n_secs, at_end)