docstr: This function computes the average statistics of a given metric.
  
  .. note::
  The statistics are stored in form of a dictionary and each key-value pair can be of string and number
  OR string and dictionary of string and number.
  
  Examples:
       {'loss': 10.0, 'top-1': 50.0}
       {'loss': {'total_loss': 10.0, 'cls_loss': 2.0, 'reg_loss': 8.0}, 'mAP': 5.0}
docstr_tok: ["This","function","computes","the","average","statistics","of","a","given","metric",".","..","note",":",":","The","statistics","are","stored","in","form","of","a","dictionary","and","each","key-value","pair","can","be","of","string","and","number","OR","string","and","dictionary","of","string","and","number",".","Examples",":","{","'loss","'",":","10.0",",","'top-1","'",":","50.0","}","{","'loss","'",":","{","'total_loss","'",":","10.0",",","'cls_loss","'",":","2.0",",","'reg_loss","'",":","8.0","}",",","'mAP","'",":","5.0","}"]
code: def avg_statistics(
      self,
      metric_name: str,
      sub_metric_name: Optional[str] = None,
      *args,
      **kwargs,
  ) -> float:
      """
      This function computes the average statistics of a given metric.
  
      .. note::
      The statistics are stored in form of a dictionary and each key-value pair can be of string and number
      OR string and dictionary of string and number.
  
      Examples:
           {'loss': 10.0, 'top-1': 50.0}
           {'loss': {'total_loss': 10.0, 'cls_loss': 2.0, 'reg_loss': 8.0}, 'mAP': 5.0}
  
      """
      if metric_name in self.metric_dict:
          computed_metric = self.metric_dict[metric_name].compute()
          computed_metric = apply_recursively(
              computed_metric,
              lambda x: round(x * 1.0, self.round_places),
          )
  
          if isinstance(computed_metric, Dict):
              if sub_metric_name is not None:
                  if sub_metric_name in computed_metric:
                      return computed_metric[sub_metric_name]
                  else:
                      logger.error(
                          "{} not present in the dictionary. Available keys are: {}".format(
                              sub_metric_name,
                              list(computed_metric.keys()),
                          )
                      )
              else:
                  return None
  
          elif isinstance(computed_metric, Number):
              return computed_metric
          else:
              return None
  
      return None
  
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 5 for calling the Statistics obj's underlying member method code with example usage: obj.avg_statistics(metric_name, sub_metric_name) and returns: None, None, computed_metric, None, computed_metric