class_docstr: Hook executed after every parameters update step. Logs training
  stats like: LR, iteration, ETA, batch time etc to logger streams.
class_docstr_tok: ["Hook","executed","after","every","parameters","update","step",".","Logs","training","stats","like",":","LR",",","iteration",",","ETA",",","batch","time","etc","to","logger","streams","."]
code: def _log_training_epoch(self, task):
      train_phase_idx = task.train_phase_idx
      log_freq = task.config["LOG_FREQUENCY"]
      iteration = task.iteration
      if torch.cuda.is_available():
          peak_mem_used = int(
              torch.cuda.max_memory_allocated() / 1024.0 / 1024.0
          )
      else:
          peak_mem_used = -1
  
      if (
          (iteration == 1)
          or (iteration % log_freq == 0)
          or (iteration <= 100 and iteration % 5 == 0)
      ):
          loss_val = round(task.last_batch.loss.data.cpu().item(), 5)
          if len(task.batch_time) > 0:
              batch_times = task.batch_time
          else:
              batch_times = [0]
          avg_time = sum(batch_times) / len(batch_times)
  
          eta_secs = avg_time * (task.max_iteration - iteration)
          eta_string = str(datetime.timedelta(seconds=int(eta_secs)))
          if isinstance(task.optimizer.options_view.lr, (set, list)):
              lr_val = list(task.optimizer.options_view.lr)
          else:
              lr_val = round(task.optimizer.options_view.lr, 5)
          if isinstance(
              task.optimizer.options_view.weight_decay, (set, list)
          ):
              wd_val = list(task.optimizer.options_view.weight_decay)
          else:
              wd_val = round(
                  task.optimizer.options_view.weight_decay, 5
              )
          batch_time = int(1000.0 * avg_time)
          rank = get_rank()
  
          log_data = {
              "Rank": rank,
              "ep": train_phase_idx,
              "iter": iteration,
              "lr": lr_val,
              "loss": loss_val,
              "btime(ms)": batch_time,
              "eta": eta_string,
              "peak_mem(M)": peak_mem_used,
              "weight_decay": wd_val,
          }
  
          # Add customized data registered by other hooks
          log_data.update(task.additional_log_data)
  
          if iteration == 1:
              # Set max iterations. Currently used in benchmark_suite_scheduler.py
              log_data["max_iterations"] = task.max_iteration
  
          if self.btime_freq and len(batch_times) >= self.btime_freq:
              rolling_avg_time = (
                  sum(batch_times[-self.btime_freq :]) / self.btime_freq
              )
              rolling_eta_secs = int(
                  rolling_avg_time * (task.max_iteration - iteration)
              )
              rolling_eta_str = str(
                  datetime.timedelta(seconds=int(rolling_eta_secs))
              )
              rolling_btime = int(1000.0 * rolling_avg_time)
              log_data[
                  f"btime({self.btime_freq}iters)(ms)"
              ] = rolling_btime
              log_data["rolling_eta"] = rolling_eta_str
  
          # to maintain the backwards compatibility with the log.txt
          # logs, we convert the json to the previous format.
          # the stdout.json can be used to use the json format of logs.
          stdout_data = ""
          for key, value in log_data.items():
              stdout_data = (
                  f"{stdout_data}[{key}: {value}] "
                  if key == "ep"
                  else f"{stdout_data}{key}: {value}; "
              )
          logging.info(stdout_data.strip())
          self.json_stdout_logger.write(json.dumps(log_data) + "\n")
  
imports: import atexit
  import datetime
  import json
  import logging
  import time
  from typing import List, Optional
  import torch
  from classy_vision import meters, tasks
  from classy_vision.generic.distributed_util import get_rank, is_primary
  from classy_vision.hooks.classy_hook import ClassyHook
  from fairscale.nn.data_parallel import FullyShardedDataParallel
  from iopath.common.file_io import g_pathmgr
  from vissl.models.model_helpers import model_output_has_nan
  from vissl.utils.checkpoint import CheckpointWriter, is_checkpoint_phase
  from vissl.utils.env import get_machine_local_and_dist_rank
  from vissl.utils.io import save_file
  from vissl.utils.logger import log_gpu_stats
  from vissl.utils.perf_stats import PerfStats
label_desc: Use image node_id 4 for calling the LogLossLrEtaHook obj's underlying member method code with example usage: obj._log_training_epoch(task) without return types