class_docstr: A class to wrap training code.
docstr: Logs a set of training steps.
code: def _summarize_shared_train(self, total_loss, raw_total_loss):
      """Logs a set of training steps."""
      cur_loss = utils.to_item(total_loss) / self.args.log_step
      # NOTE(brendan): The raw loss, without adding in the activation
      # regularization terms, should be used to compute ppl.
      cur_raw_loss = utils.to_item(raw_total_loss) / self.args.log_step
      ppl = math.exp(cur_raw_loss)
  
      logger.info(
          f"| epoch {self.epoch:3d} "
          f"| lr {self.shared_lr:4.2f} "
          f"| raw loss {cur_raw_loss:.2f} "
          f"| loss {cur_loss:.2f} "
          f"| ppl {ppl:8.2f}"
      )
  
      # Tensorboard
      if self.tb is not None:
          self.tb.scalar_summary(
              "shared/loss", cur_loss, self.shared_step
          )
          self.tb.scalar_summary(
              "shared/perplexity", ppl, self.shared_step
          )
  
imports: import contextlib
  import glob
  import math
  import os
  import numpy
  import scipy.signal
  from tensorboard import TensorBoard
  import torch
  from torch import nn
  import torch.nn.parallel
  from torch.autograd import Variable
  import models
  import utils
label_desc: Use image node_id 19 for calling the Trainer obj's underlying member method code with example usage: obj._summarize_shared_train(total_loss, raw_total_loss) without return types