docstr: Sends all of the train metrics (and validation metrics, if provided) to tensorboard.
docstr_tok: ["Sends","all","of","the","train","metrics","(","and","validation","metrics",",","if","provided",")","to","tensorboard","."]
code: def _metrics_to_tensorboard(
      self, epoch, train_metrics, val_metrics=None
  ):
      """
      Sends all of the train metrics (and validation metrics, if provided) to tensorboard.
      """
      metric_names = set(train_metrics.keys())
      if val_metrics is not None:
          metric_names.update(list(val_metrics.keys()))
      val_metrics = val_metrics or {}
  
      for name in metric_names:
          train_metric = train_metrics.get(name)
          if train_metric is not None:
              self._tensorboard.add_train_scalar(
                  name, train_metric, epoch
              )
          val_metric = val_metrics.get(name)
          if val_metric is not None:
              self._tensorboard.add_validation_scalar(
                  name, val_metric, epoch
              )
  
imports: from __future__ import with_statement
  from __future__ import division
  from __future__ import absolute_import
  import logging
  import os
  import shutil
  import time
  import re
  import datetime
  import traceback
  import torch
  import torch.optim.lr_scheduler
  from torch.nn.parallel import replicate, parallel_apply
  from torch.nn.parallel.scatter_gather import scatter_kwargs, gather
  from allennlp.common import Params
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.util import peak_memory_mb, gpu_memory_mb
  from allennlp.common.tqdm import Tqdm
  from allennlp.data.instance import Instance
  from allennlp.data.iterators.data_iterator import DataIterator
  from allennlp.models.model import Model
  from allennlp.nn import util
  from allennlp.training.learning_rate_schedulers import LearningRateScheduler
  from allennlp.training.optimizers import Optimizer
label_desc: Use image node_id 12 for calling the Trainer obj's underlying member method code with example usage: obj._metrics_to_tensorboard(epoch, train_metrics, val_metrics) without return types