class_docstr: Hook for writing the losses, learning rates and meters to `tensorboard <https
  ://www.tensorflow.org/tensorboard`>_.
  
  Global steps are counted in terms of the number of samples processed.
class_docstr_tok: ["Hook","for","writing","the","losses",",","learning","rates","and","meters","to","`","tensorboard","<","https",":","\/\/www.tensorflow.org\/tensorboard","`",">","_",".","Global","steps","are","counted","in","terms","of","the","number","of","samples","processed","."]
docstr: The constructor method of TensorboardPlotHook.
  
  Args:
      tb_writer: `Tensorboard SummaryWriter <https://tensorboardx.
      readthedocs.io/en/latest/tensorboard.html#tensorboardX.
      SummaryWriter>`_ instance or None (only on secondary replicas)
docstr_tok: ["The","constructor","method","of","TensorboardPlotHook",".","Args",":","tb_writer",":","`","Tensorboard","SummaryWriter","<","https",":","\/\/tensorboardx",".","readthedocs.io\/en\/latest\/tensorboard.html","#","tensorboardX",".","SummaryWriter",">","`","_","instance","or","None","(","only","on","secondary","replicas",")"]
code: def __init__(self, tb_writer, log_period: int = 10) -> None:
      """The constructor method of TensorboardPlotHook.
  
      Args:
          tb_writer: `Tensorboard SummaryWriter <https://tensorboardx.
          readthedocs.io/en/latest/tensorboard.html#tensorboardX.
          SummaryWriter>`_ instance or None (only on secondary replicas)
      """
      super().__init__()
      if not tb_available:
          raise ModuleNotFoundError(
              "tensorboard not installed, cannot use TensorboardPlotHook"
          )
      if not isinstance(log_period, int):
          raise TypeError("log_period must be an int")
      self.tb_writer = tb_writer
      self.learning_rates: Optional[List[float]] = None
      self.wall_times: Optional[List[float]] = None
      self.sample_fetch_times: Optional[List[float]] = None
      self.log_period = log_period
      # need to maintain the step count at the end of every phase
      # and the cumulative sample fetch time for checkpointing
      self.state.step_count = {"train": 0, "test": 0}
      self.state.cum_sample_fetch_time = {"train": 0, "test": 0}
  
file_path: ClassyVision/classy_vision/hooks/tensorboard_plot_hook.py
imports: import logging
  import time
  from itertools import accumulate
  from typing import Any, Dict, List, Optional, Tuple
  import torch
  from classy_vision.generic.distributed_util import all_reduce_max, is_primary
  from classy_vision.hooks import register_hook
  from classy_vision.hooks.classy_hook import ClassyHook
label_desc: Use image node_id 1 to create a new TensorboardPlotHook object from inherited base classes: ClassyHook with example: obj = TensorboardPlotHook(tb_writer, log_period)