class_docstr: Statistics of samples that are dictionaries with constant set of keys.
  
  For example the following are equivalent::
  
      # Version 1. Hand encode statistics.
      >>> a_stats = CountStats()
      >>> b_stats = CountMeanStats()
      >>> a_stats.update(torch.tensor(0.))
      >>> b_stats.update(torch.tensor([1., 2.]))
      >>> summary = {"a": a_stats.get(), "b": b_stats.get()}
  
      # Version 2. Collect samples into dictionaries.
      >>> stats = StatsOfDict({"a": CountStats, "b": CountMeanStats})
      >>> stats.update({"a": torch.tensor(0.), "b": torch.tensor([1., 2.])})
      >>> summary = stats.get()
      >>> summary
      {'a': {'count': 1}, 'b': {'count': 1, 'mean': tensor([1., 2.])}}
  
  :param default: Default type of statistics of values of the dictionary.
      Defaults to the inexpensive :class:`CountStats`.
  :param dict types: Dictionary mapping key to type of statistic that should
      be recorded for values corresponding to that key.
code: def __init__(
      self,
      types: Dict[Hashable, Callable[[], StreamingStats]] = {},
      default: Callable[[], StreamingStats] = CountStats,
  ):
      self.stats: Dict[Hashable, StreamingStats] = defaultdict(default)
      self.stats.update({k: v() for k, v in types.items()})
      super().__init__()
  
imports: import copy
  from abc import ABC, abstractmethod
  from collections import defaultdict
  from typing import Any, Callable, Dict, Hashable, Union
  import torch
  from pyro.ops.welford import WelfordCovariance
label_desc: Use image node_id 1 to create a new StatsOfDict object from inherited base classes: StreamingStats with example: obj = StatsOfDict(types, default)