class_docstr: A callback that writes training statistics/metrics to TensorBoard.
class_docstr_tok: ["A","callback","that","writes","training","statistics\/metrics","to","TensorBoard","."]
code: def __init__(
      self,
      serialization_dir: str,
      summary_interval: int = 100,
      distribution_interval: Optional[int] = None,
      batch_size_interval: Optional[int] = None,
      should_log_parameter_statistics: bool = False,
      should_log_learning_rate: bool = False,
  ) -> None:
      super().__init__(
          serialization_dir,
          summary_interval=summary_interval,
          distribution_interval=distribution_interval,
          batch_size_interval=batch_size_interval,
          should_log_parameter_statistics=should_log_parameter_statistics,
          should_log_learning_rate=should_log_learning_rate,
      )
  
      # Create log directories prior to creating SummaryWriter objects
      # in order to avoid race conditions during distributed training.
      train_ser_dir = os.path.join(
          self.serialization_dir, "log", "train"
      )
      os.makedirs(train_ser_dir, exist_ok=True)
      self._train_log = SummaryWriter(train_ser_dir)
      val_ser_dir = os.path.join(
          self.serialization_dir, "log", "validation"
      )
      os.makedirs(val_ser_dir, exist_ok=True)
      self._validation_log = SummaryWriter(val_ser_dir)
  
file_path: allennlp/allennlp/training/callbacks/tensorboard.py
imports: import os
  from typing import Dict, Union, Optional
  from tensorboardX import SummaryWriter
  import torch
  from allennlp.training.callbacks.callback import TrainerCallback
  from allennlp.training.callbacks.log_writer import LogWriterCallback
label_desc: Use image node_id 1 to create a new TensorBoardCallback object from inherited base classes: LogWriterCallback with example: obj = TensorBoardCallback(serialization_dir, summary_interval, distribution_interval, batch_size_interval, should_log_parameter_statistics, should_log_learning_rate)