class_docstr: A callback which logs iteration times as scalars to TensorBoard.
  
  Args:
      logger: Either a :class:`torchtnt.loggers.tensorboard.TensorBoardLogger`
          or a :class:`torch.utils.tensorboard.SummaryWriter` instance.
      moving_avg_window: an optional int to control the moving average window
      log_every_n_steps: an optional int to control the log frequency
code: def __init__(
      self,
      logger: Union[TensorBoardLogger, SummaryWriter],
      moving_avg_window: int = 1,
      log_every_n_steps: int = 1,
  ) -> None:
      if isinstance(logger, TensorBoardLogger):
          logger = logger.writer
  
      if get_global_rank() == 0:  # only write from the main rank
          self._writer = none_throws(
              logger, "TensorBoardLogger.writer should not be None"
          )
      self.moving_avg_window = moving_avg_window
      self.log_every_n_steps = log_every_n_steps
  
file_path: tnt/torchtnt/framework/callbacks/iteration_time_logger.py
imports: from typing import Optional, Union
  from pyre_extensions import none_throws
  from torch.utils.tensorboard import SummaryWriter
  from torchtnt.framework.callback import Callback
  from torchtnt.framework.state import State
  from torchtnt.framework.unit import TEvalUnit, TPredictUnit, TTrainUnit
  from torchtnt.utils.distributed import get_global_rank
  from torchtnt.utils.loggers.tensorboard import TensorBoardLogger
  from torchtnt.utils.timer import TimerProtocol
label_desc: Use image node_id 1 to create a new IterationTimeLogger object from inherited base classes: Callback with example: obj = IterationTimeLogger(logger, moving_avg_window, log_every_n_steps)