class_docstr: A class collecting a set of metrics.
  
  When defining the stats produced by a certain operation (say, training or
  evaluation), subclass this class, decorate it with @stats and define the
  metrics you want to collect as class attributes with type annotations whose
  values are attr.ib() instances. A metric named count is automatically added.
  Doing this automatically gives you space-optimized classes (using slots)
  equipped with the most common magic methods (__init__, __eq__, ...) plus
  some convenience methods to aggregate, convert and format stats (see below).
class_docstr_tok: ["A","class","collecting","a","set","of","metrics",".","When","defining","the","stats","produced","by","a","certain","operation","(","say",",","training","or","evaluation",")",",","subclass","this","class",",","decorate","it","with","@","stats","and","define","the","metrics","you","want","to","collect","as","class","attributes","with","type","annotations","whose","values","are","attr.ib","(",")","instances",".","A","metric","named","count","is","automatically","added",".","Doing","this","automatically","gives","you","space-optimized","classes","(","using","slots",")","equipped","with","the","most","common","magic","methods","(","__init__",",","__eq__",",","...",")","plus","some","convenience","methods","to","aggregate",",","convert","and","format","stats","(","see","below",")","."]
code: def from_dict(cls, d: SerializedStats) -> "Stats":
      if set(d.keys()) != {"count", "metrics"}:
          raise ValueError(
              f"Expect keys ['count', 'metrics'] from input but get {list(d.keys())}."
          )
      return Stats(
          count=cast(int, d["count"]),
          **cast(Dict[str, float], d["metrics"]),
      )
  
file_path: PyTorch-BigGraph/torchbiggraph/stats.py
imports: from collections import defaultdict
  from statistics import mean
  from typing import cast, Dict, Iterable, Optional, Type, Union
  from torchbiggraph.types import FloatTensorType
label_desc: Use image node_id 9 for calling the Stats obj's underlying member method code with example usage: obj.from_dict(cls, d) and returns: Stats