code: def __init__(
      self,
      opts: argparse.Namespace,
      metric_names: list = ["loss"],
      is_master_node: Optional[bool] = False,
      is_distributed: Optional[bool] = False,
      log_writers: Optional[List] = [],
  ) -> None:
      if len(metric_names) == 0:
          logger.error("Metric names list cannot be empty")
  
      # key is the metric name and value is the value
      self.metric_dict: Dict[str, BaseMetric] = {}
      for m_name in metric_names:
          if m_name in METRICS_REGISTRY:
              self.metric_dict[m_name] = METRICS_REGISTRY[m_name](
                  opts=opts, is_distributed=is_distributed
              )
          else:
              if is_master_node:
                  logger.log(
                      "{} statistics not supported. Supported: {}".format(
                          m_name, METRICS_REGISTRY.keys()
                      )
                  )
  
      self.round_places = 4
      self.is_master_node = is_master_node
      self.log_writers = log_writers
  
      self.batch_time = 0
      self.batch_counter = 0
  
imports: import argparse
  import sys
  import time
  import traceback
  from numbers import Number
  from typing import Any, Dict, List, Optional, Union
  import numpy
  import torch
  from torch import Tensor
  from metrics import METRICS_REGISTRY
  from metrics.metric_base import BaseMetric
  from utils import logger
  from utils.object_utils import apply_recursively, flatten_to_dict
label_desc: Use image node_id 1 to create a new Statistics object from inherited base classes: object with example: obj = Statistics(opts, metric_names, is_master_node, is_distributed, log_writers)