class_docstr: Log objects to tensorboard.
code: def __init__(self, opt: Opt):
      try:
          # tensorboard is a very expensive thing to import. Wait until the
          # last second to import it.
          from tensorboardX import SummaryWriter
      except ImportError:
          raise ImportError(
              "Please run `pip install tensorboard tensorboardX`."
          )
  
      if opt["tensorboard_logdir"] is not None:
          tbpath = opt["tensorboard_logdir"]
      else:
          tbpath = opt["model_file"] + ".tensorboard"
  
      logging.debug(f"Saving tensorboard logs to: {tbpath}")
      if not PathManager.exists(tbpath):
          PathManager.mkdirs(tbpath)
      self.writer = SummaryWriter(tbpath, comment=json.dumps(opt))
  
imports: import datetime
  import json
  import numbers
  import os
  import pathlib
  import re
  from typing import Optional
  import parlai.utils.logging
  from parlai.core.metrics import Metric, dict_report, get_metric_display_data
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.utils.io import PathManager
label_desc: Use image node_id 2 to create a new TensorboardLogger object from inherited base classes: object with example: obj = TensorboardLogger(opt)