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
docstr: Helper function to write a timing log message to writer based on how the class
  was configured.
docstr_tok: ["Helper","function","to","write","a","timing","log","message","to","writer","based","on","how","the","class","was","configured","."]
code: def _log_step_metrics(
      self,
      writer: SummaryWriter,
      metric_label: str,
      iteration_timer: TimerProtocol,
      step_logging_for: int,
  ) -> None:
      """
      Helper function to write a timing log message to writer based on how the class
      was configured.
  
      """
      if step_logging_for % self.log_every_n_steps != 0:
          return
  
      human_metric_names = {
          "train_iteration_time": "Train Iteration Time (seconds)",
          "eval_iteration_time": "Eval Iteration Time (seconds)",
          "predict_iteration_time": "Prediction Iteration Time (seconds)",
      }
  
      time_list = iteration_timer.recorded_durations.get(
          metric_label, []
      )
      if not time_list:
          return
  
      last_n_values = time_list[-self.moving_avg_window :]
      writer.add_scalar(
          human_metric_names[metric_label],
          sum(last_n_values) / len(last_n_values),
          step_logging_for,
      )
  
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 2 for calling the IterationTimeLogger obj's underlying member method code with example usage: obj._log_step_metrics(writer, metric_label, iteration_timer, step_logging_for) without return types