class_docstr: An abstract baseclass for callbacks that Log training statistics and metrics.
  Examples of concrete implementations are the `TensorBoardCallback` and `WandBCallback`.
  
  # Parameters
  
  serialization_dir : `str`
      The training serialization directory.
  
      In a typical AllenNLP configuration file, this parameter does not get an entry in the
      file, it gets passed in separately.
  
  summary_interval : `int`, optional (default = `100`)
      Most statistics will be written out only every this many batches.
  
  distribution_interval : `int`, optional (default = `None`)
      When this parameter is specified, the following additional logging is enabled
      every this many batches:
  
          * Distributions of model parameters
          * The ratio of parameter update norm to parameter norm
          * Distribution of layer activations
  
      The layer activations are logged for any modules in the `Model` that have
      the attribute `should_log_activations` set to `True`.
  
      Logging distributions requires a number of GPU-CPU copies during training and is typically
      slow, so we recommend logging distributions relatively infrequently.
  
      !!! Note
          Only Modules that return tensors, tuples of tensors or dicts
          with tensors as values currently support activation logging.
  
  batch_size_interval : `int`, optional, (default = `None`)
      If defined, how often to log the average batch size.
  
  should_log_parameter_statistics : `bool`, optional (default = `True`)
      Whether to log parameter statistics (mean and standard deviation of parameters and
      gradients). If `True`, parameter stats are logged every `summary_interval` batches.
  
  should_log_learning_rate : `bool`, optional (default = `False`)
      Whether to log (parameter-specific) learning rate.
      If `True`, learning rates are logged every `summary_interval` batches.
  
  batch_loss_moving_average_count : `int`, optional (default = `100`)
      The length of the moving average for batch loss.
docstr: Required to be implemented by subclasses.
  
  Defines how batch or epoch tensor metrics are logged.
docstr_tok: ["Required","to","be","implemented","by","subclasses",".","Defines","how","batch","or","epoch","tensor","metrics","are","logged","."]
code: def log_tensors(
      self,
      tensors: Dict[str, torch.Tensor],
      log_prefix: str = "",
      epoch: Optional[int] = None,
  ) -> None:
      """
      Required to be implemented by subclasses.
  
      Defines how batch or epoch tensor metrics are logged.
      """
      raise NotImplementedError
  
imports: from collections import deque, defaultdict
  import logging
  from typing import List, Dict, Any, Optional, TYPE_CHECKING, Union, Deque, Set
  import torch
  from allennlp.data import TensorDict
  from allennlp.nn.util import tiny_value_of_dtype
  from allennlp.training.callbacks.callback import TrainerCallback
  from allennlp.training.util import get_train_and_validation_metrics, get_batch_size
label_desc: Use image node_id 3 for calling the LogWriterCallback obj's underlying member method code with example usage: obj.log_tensors(tensors, log_prefix, epoch) without return types