class_docstr: Computes and prints performance metrics. Logs at the end of a phase
  or every log_freq if specified by user.
class_docstr_tok: ["Computes","and","prints","performance","metrics",".","Logs","at","the","end","of","a","phase","or","every","log_freq","if","specified","by","user","."]
docstr: Compute and log performance metrics.
docstr_tok: ["Compute","and","log","performance","metrics","."]
code: def _log_performance_metrics(self, task: "tasks.ClassyTask") -> None:
      """
      Compute and log performance metrics.
      """
      phase_type = task.phase_type
      batches = len(task.losses)
  
      if self.start_time is None:
          logging.warning("start_time not initialized")
      else:
          # Average batch time calculation
          total_batch_time = time.time() - self.start_time
          average_batch_time = total_batch_time / batches
          logging.info(
              "Average %s batch time (ms) for %d batches: %d"
              % (phase_type, batches, 1000.0 * average_batch_time)
          )
  
      # Train step time breakdown
      if task.perf_stats is None:
          logging.warning('"perf_stats" not set in local_variables')
      elif task.train:
          logging.info(
              "Train step time breakdown (rank {}):\n{}".format(
                  get_rank(), task.perf_stats.report_str()
              )
          )
  
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 5 for calling the LogPerfTimeMetricsHook obj's underlying member method code with example usage: obj._log_performance_metrics(task) without return types