class_docstr: Logs the loss, optimizer LR, and meters. Logs at the end of a phase.
docstr: Compute and log the loss, lr, and meters.
code: def _log_loss_lr_meters(
      self, task, prefix="", log_batches=False
  ) -> None:
      """
      Compute and log the loss, lr, and meters.
      """
  
      phase_type = task.phase_type
      phase_type_idx = (
          task.train_phase_idx if task.train else task.eval_phase_idx
      )
      batches = len(task.losses)
  
      # Loss for the phase
      loss = sum(task.losses) / batches
      phase_pct = batches / task.num_batches_per_phase
      msg = (
          f"{prefix}[{get_rank()}] {phase_type} phase {phase_type_idx} "
          f"({phase_pct*100:.2f}% done), loss: {loss:.4f}, meters: {task.meters}"
      )
      if task.train:
          msg += f", lr: {task.optimizer.options_view.lr:.4f}"
      if phase_type == "test" and hasattr(task, "ema"):
          msg += f", ema: {task.ema}"
      if log_batches:
          msg += f", processed batches: {batches}"
  
      logging.info(msg)
  
file_path: ClassyVision/classy_vision/hooks/loss_lr_meter_logging_hook.py
imports: import logging
  from typing import Optional
  from classy_vision.generic.distributed_util import get_rank
  from classy_vision.hooks import register_hook
  from classy_vision.hooks.classy_hook import ClassyHook
label_desc: Use image node_id 5 for calling the LossLrMeterLoggingHook obj's underlying member method code with example usage: obj._log_loss_lr_meters(task, prefix, log_batches) without return types