class_docstr: Stats logging object useful for gathering statistics of training
  a deep network in PyTorch.
  
  Example:
      ```
      # Init stats structure that logs statistics 'objective' and 'top1e'.
      stats = Stats( ('objective','top1e') )
  
      network = init_net()  # init a pytorch module (=neural network)
      dataloader = init_dataloader()  # init a dataloader
  
      for epoch in range(10):
  
          # start of epoch -> call new_epoch
          stats.new_epoch()
  
          # Iterate over batches.
          for batch in dataloader:
              # Run a model and save into a dict of output variables "output"
              output = network(batch)
  
              # stats.update() automatically parses the 'objective' and 'top1e'
              # from the "output" dict and stores this into the db.
              stats.update(output)
              stats.print() # prints the averages over given epoch
  
          # Stores the training plots into '/tmp/epoch_stats.pdf'
          # and plots into a visdom server running at localhost (if running).
          stats.plot_stats(plot_file='/tmp/epoch_stats.pdf')
      ```
docstr: Update the internal logs with metrics of a training step.
  
  Each metric is stored as an instance of an AverageMeter.
  
  Args:
      preds: Dict of values to be added to the logs.
      stat_set: The set of statistics to be updated (e.g. "train", "val").
docstr_tok: ["Update","the","internal","logs","with","metrics","of","a","training","step",".","Each","metric","is","stored","as","an","instance","of","an","AverageMeter",".","Args",":","preds",":","Dict","of","values","to","be","added","to","the","logs",".","stat_set",":","The","set","of","statistics","to","be","updated","(","e.g",".","``","train","''",",","``","val","''",")","."]
code: def update(self, preds: dict, stat_set: str = "train") -> None:
      """
      Update the internal logs with metrics of a training step.
  
      Each metric is stored as an instance of an AverageMeter.
  
      Args:
          preds: Dict of values to be added to the logs.
          stat_set: The set of statistics to be updated (e.g. "train", "val").
      """
  
      if self.epoch == -1:  # uninitialized
          warnings.warn(
              "self.epoch==-1 means uninitialized stats structure"
              " -> new_epoch() called"
          )
          self.new_epoch()
  
      if stat_set not in self.stats:
          self.stats[stat_set] = {}
          self.it[stat_set] = -1
  
      self.it[stat_set] += 1
  
      epoch = self.epoch
      it = self.it[stat_set]
  
      for stat in self.log_vars:
          if stat not in self.stats[stat_set]:
              self.stats[stat_set][stat] = AverageMeter()
  
          if stat == "sec/it":  # compute speed
              elapsed = time.time() - self._epoch_start
              time_per_it = float(elapsed) / float(it + 1)
              val = time_per_it
          else:
              if stat in preds:
                  val = self._gather_value(preds[stat])
              else:
                  val = None
  
          if val is not None:
              self.stats[stat_set][stat].update(val, epoch=epoch, n=1)
  
imports: import time
  import warnings
  from itertools import cycle
  from typing import List, Optional
  import matplotlib
  import matplotlib.pyplot
  import numpy
  from matplotlib import colors
  from visdom import Visdom
label_desc: Use image node_id 6 for calling the Stats obj's underlying member method code with example usage: obj.update(preds, stat_set) without return types