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 _plot_stats(self, keys: Sequence[str], key2: str):
      assert check_argument_types()
      # str is also Sequence[str]
      if isinstance(keys, str):
          raise TypeError(f"Input as [{keys}]")
  
      import matplotlib
  
      matplotlib.use("agg")
      import matplotlib.pyplot as plt
      import matplotlib.ticker as ticker
  
      plt.clf()
  
      epochs = np.arange(1, self.get_epoch() + 1)
      for key in keys:
          y = [
              self.stats[e][key][key2]
              if e in self.stats
              and key in self.stats[e]
              and key2 in self.stats[e][key]
              else np.nan
              for e in epochs
          ]
          assert len(epochs) == len(y), "Bug?"
  
          plt.plot(epochs, y, label=key, marker="x")
      plt.legend()
      plt.title(f"{key2} vs epoch")
      # Force integer tick for x-axis
      plt.gca().get_xaxis().set_major_locator(
          ticker.MaxNLocator(integer=True)
      )
      plt.xlabel("epoch")
      plt.ylabel(key2)
      plt.grid()
  
      return plt
  
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 19 for calling the Reporter obj's underlying member method code with example usage: obj._plot_stats(keys, key2) and returns: plt