docstr: Gets the metrics but sets ``"loss"`` to
  the total loss divided by the ``num_batches`` so that
  the ``"loss"`` metric is "average loss per batch".
docstr_tok: ["Gets","the","metrics","but","sets","``","``","loss","''","``","to","the","total","loss","divided","by","the","``","num_batches","``","so","that","the","``","``","loss","''","``","metric","is","``","average","loss","per","batch","''","."]
code: def _get_metrics(self, total_loss, num_batches, reset=False):
      """
      Gets the metrics but sets ``"loss"`` to
      the total loss divided by the ``num_batches`` so that
      the ``"loss"`` metric is "average loss per batch".
      """
      metrics = self._model.get_metrics(reset=reset)
      metrics["loss"] = (
          float(total_loss / num_batches) if num_batches > 0 else 0.0
      )
      return metrics
  
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 7 for calling the Trainer obj's underlying member method code with example usage: obj._get_metrics(total_loss, num_batches, reset) and returns: metrics