class_docstr: TrainLoop contains the core training loop logic.
class_docstr_tok: ["TrainLoop","contains","the","core","training","loop","logic","."]
docstr: Output a training log entry.
docstr_tok: ["Output","a","training","log","entry","."]
code: def log(self):
      """
      Output a training log entry.
      """
      opt = self.opt
      if opt["display_examples"]:
          print(self.world.display() + "\n~~")
      logs = []
      # get report
      train_report = self.world.report()
      train_report = self._sync_metrics(train_report)
      self.world.reset_metrics()
  
      train_report_trainstats = dict_report(train_report)
      train_report_trainstats["total_epochs"] = self._total_epochs
      train_report_trainstats["total_exs"] = self._total_exs
      train_report_trainstats["parleys"] = self.parleys
      train_report_trainstats["train_steps"] = self._train_steps
      train_report_trainstats["train_time"] = self.train_time.time()
      self.train_reports.append(train_report_trainstats)
  
      # time elapsed
      logs.append(f"time:{self.train_time.time():.0f}s")
      logs.append(f"total_exs:{self._total_exs}")
      logs.append(f"total_steps:{self._train_steps}")
  
      if self._total_epochs >= 0:
          # only if it's unbounded
          logs.append(f"epochs:{self._total_epochs:.2f}")
  
      time_left = self._compute_eta(
          self._total_epochs, self.train_time.time(), self._train_steps
      )
      if time_left is not None:
          logs.append(f"time_left:{max(0,time_left):.0f}s")
  
      log = "{}\n{}\n".format(" ".join(logs), nice_report(train_report))
      logging.info(log)
      self.log_time.reset()
      self._last_log_steps = 0
  
      if opt["tensorboard_log"] and is_primary_worker():
          self.tb_logger.log_metrics(
              "train", self.parleys, train_report
          )
      if opt["wandb_log"] and is_primary_worker():
          self.wb_logger.log_metrics(
              "train", self.parleys, train_report
          )
      if opt["clearml_log"] and is_primary_worker():
          self.clearml_logger.log_metrics(
              "train", self.parleys, train_report
          )
  
      return train_report
  
imports: import copy
  import random
  import torch
  import json
  import os
  import signal
  from typing import Tuple
  import numpy
  import parlai.utils.logging
  from parlai.core.agents import create_agent, create_agent_from_shared
  from parlai.core.exceptions import StopTrainException
  from parlai.core.logs import TensorboardLogger, WandbLogger, ClearMLLogger
  from parlai.core.metrics import Metric
  from parlai.core.metrics import aggregate_named_reports, aggregate_unnamed_reports, dict_report
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser, print_announcements
  from parlai.core.script import ParlaiScript, register_script
  from parlai.core.worlds import create_task, World
  from parlai.scripts.build_dict import build_dict, setup_args
  from parlai.scripts.eval_model import get_task_world_logs
  from parlai.utils.distributed import sync_object, is_primary_worker, all_gather_list, is_distributed, get_rank, num_workers
  from parlai.utils.io import PathManager
  from parlai.utils.misc import Timer, nice_report
  from parlai.utils.world_logging import WorldLogger
label_desc: Use image node_id 11 for calling the TrainLoop obj's underlying member method code with example usage: obj.log() and returns: train_report