class_docstr: Reporter class.
  
  Examples:
  
      >>> reporter = Reporter()
      >>> with reporter.observe('train') as sub_reporter:
      ...     for batch in iterator:
      ...         stats = dict(loss=0.2)
      ...         sub_reporter.register(stats)
class_docstr_tok: ["Reporter","class",".","Examples",":",">",">",">","reporter","=","Reporter","(",")",">",">",">","with","reporter.observe","(","'train","'",")","as","sub_reporter",":","...","for","batch","in","iterator",":","...","stats","=","dict","(","loss=0.2",")","...","sub_reporter.register","(","stats",")"]
code: def finish_epoch(self, sub_reporter: SubReporter) -> None:
      if self.epoch != sub_reporter.epoch:
          raise RuntimeError(
              f"Don't change epoch during observation: "
              f"{self.epoch} != {sub_reporter.epoch}"
          )
  
      # Calc mean of current stats and set it as previous epochs stats
      stats = {}
      for key2, values in sub_reporter.stats.items():
          v = aggregate(values)
          stats[key2] = v
  
      stats["time"] = datetime.timedelta(
          seconds=time.perf_counter() - sub_reporter.start_time
      )
      stats["total_count"] = sub_reporter.total_count
      if V(torch.__version__) >= V("1.4.0"):
          if torch.cuda.is_initialized():
              stats["gpu_max_cached_mem_GB"] = (
                  torch.cuda.max_memory_reserved() / 2**30
              )
      else:
          if (
              torch.cuda.is_available()
              and torch.cuda.max_memory_cached() > 0
          ):
              stats["gpu_cached_mem_GB"] = (
                  torch.cuda.max_memory_cached() / 2**30
              )
  
      self.stats.setdefault(self.epoch, {})[sub_reporter.key] = stats
      sub_reporter.finished()
  
imports: import dataclasses
  import datetime
  import logging
  import time
  import warnings
  from collections import defaultdict
  from contextlib import contextmanager
  from pathlib import Path
  from typing import ContextManager, Dict, List, Optional, Sequence, Tuple, Union
  import humanfriendly
  import numpy
  import torch
  from packaging.version import parse
  from typeguard import check_argument_types, check_return_type
label_desc: Use image node_id 6 for calling the Reporter obj's underlying member method code with example usage: obj.finish_epoch(sub_reporter) without return types