class_docstr: Helper class to log information to Tensorboard.
class_docstr_tok: ["Helper","class","to","log","information","to","Tensorboard","."]
docstr: Args:
      cfg (CfgNode): configs. Details can be found in
          slowfast/config/defaults.py
docstr_tok: ["Args",":","cfg","(","CfgNode",")",":","configs",".","Details","can","be","found","in","slowfast\/config\/defaults.py"]
code: def __init__(self, cfg):
      """
      Args:
          cfg (CfgNode): configs. Details can be found in
              slowfast/config/defaults.py
      """
      # class_names: list of class names.
      # cm_subset_classes: a list of class ids -- a user-specified subset.
      # parent_map: dictionary where key is the parent class name and
      #   value is a list of ids of its children classes.
      # hist_subset_classes: a list of class ids -- user-specified to plot histograms.
      (
          self.class_names,
          self.cm_subset_classes,
          self.parent_map,
          self.hist_subset_classes,
      ) = (None, None, None, None)
      self.cfg = cfg
      self.cm_figsize = cfg.TENSORBOARD.CONFUSION_MATRIX.FIGSIZE
      self.hist_figsize = cfg.TENSORBOARD.HISTOGRAM.FIGSIZE
  
      if cfg.TENSORBOARD.LOG_DIR == "":
          log_dir = os.path.join(
              cfg.OUTPUT_DIR, "runs-{}".format(cfg.TRAIN.DATASET)
          )
      else:
          log_dir = os.path.join(
              cfg.OUTPUT_DIR, cfg.TENSORBOARD.LOG_DIR
          )
  
      self.writer = SummaryWriter(log_dir=log_dir)
      logger.info(
          "To see logged results in Tensorboard, please launch using the command \
              `tensorboard  --port=<port-number> --logdir {}`".format(
              log_dir
          )
      )
  
      if cfg.TENSORBOARD.CLASS_NAMES_PATH != "":
          if cfg.DETECTION.ENABLE:
              logger.info(
                  "Plotting confusion matrix is currently \
                      not supported for detection."
              )
          (
              self.class_names,
              self.parent_map,
              self.cm_subset_classes,
          ) = get_class_names(
              cfg.TENSORBOARD.CLASS_NAMES_PATH,
              cfg.TENSORBOARD.CATEGORIES_PATH,
              cfg.TENSORBOARD.CONFUSION_MATRIX.SUBSET_PATH,
          )
  
          if cfg.TENSORBOARD.HISTOGRAM.ENABLE:
              if cfg.DETECTION.ENABLE:
                  logger.info(
                      "Plotting histogram is not currently \
                      supported for detection tasks."
                  )
              if cfg.TENSORBOARD.HISTOGRAM.SUBSET_PATH != "":
                  _, _, self.hist_subset_classes = get_class_names(
                      cfg.TENSORBOARD.CLASS_NAMES_PATH,
                      None,
                      cfg.TENSORBOARD.HISTOGRAM.SUBSET_PATH,
                  )
  
imports: import logging
  import math
  import os
  import matplotlib.pyplot
  import torch
  from torch.utils.tensorboard import SummaryWriter
  from torchvision.utils import make_grid
  import slowfast.utils.logging
  import slowfast.visualization.utils
  from slowfast.utils.misc import get_class_names
label_desc: Use image node_id 1 to create a new TensorboardWriter object  with example: obj = TensorboardWriter(cfg)