docstr: Logs all of the train metrics (and validation metrics, if provided) to the console.
docstr_tok: ["Logs","all","of","the","train","metrics","(","and","validation","metrics",",","if","provided",")","to","the","console","."]
code: def _metrics_to_console(
      self,  # pylint: disable=no-self-use
      train_metrics,
      val_metrics=None,
  ):
      """
      Logs all of the train metrics (and validation metrics, if provided) to the console.
      """
      val_metrics = val_metrics or {}
      dual_message_template = "%s |  %8.3f  |  %8.3f"
      no_val_message_template = "%s |  %8.3f  |  %8s"
      no_train_message_template = "%s |  %8s  |  %8.3f"
      header_template = "%s |  %-10s"
  
      metric_names = set(train_metrics.keys())
      if val_metrics:
          metric_names.update(list(val_metrics.keys()))
  
      name_length = max([len(x) for x in metric_names])
  
      logger.info(
          header_template,
          "Training".rjust(name_length + 13),
          "Validation",
      )
      for name in metric_names:
          train_metric = train_metrics.get(name)
          val_metric = val_metrics.get(name)
  
          if val_metric is not None and train_metric is not None:
              logger.info(
                  dual_message_template,
                  name.ljust(name_length),
                  train_metric,
                  val_metric,
              )
          elif val_metric is not None:
              logger.info(
                  no_train_message_template,
                  name.ljust(name_length),
                  "N/A",
                  val_metric,
              )
          elif train_metric is not None:
              logger.info(
                  no_val_message_template,
                  name.ljust(name_length),
                  train_metric,
                  "N/A",
              )
  
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 13 for calling the Trainer obj's underlying member method code with example usage: obj._metrics_to_console(train_metrics, val_metrics) without return types