class_docstr: Class that manages the training loop. See speechbrain.core.Brain.
  
  Arguments
  ---------
  modules : dict of str:torch.nn.Module pairs
      These modules are passed to the optimizer by default if they have
      trainable parameters, and will have ``train()``/``eval()`` called on them.
  opt_class : torch.optim class
      A torch optimizer constructor that takes only the list of
      parameters (e.g. a lambda or partial function definition). By default,
      this will be passed all modules in ``modules`` at the
      beginning of the ``fit()`` method. This behavior can be changed
      by overriding the ``configure_optimizers()`` method.
  hparams : dict
      Each key:value pair should consist of a string key and a hyperparameter
      that is used within the overridden methods. These will
      be accessible via an ``hparams`` attribute, using "dot" notation:
      e.g., self.hparams.model(x).
  run_opts : dict
      A set of options to change the runtime environment.
class_docstr_tok: ["Class","that","manages","the","training","loop",".","See","speechbrain.core.Brain",".","Arguments","--","--","--","--","-","modules",":","dict","of","str",":","torch.nn.Module","pairs","These","modules","are","passed","to","the","optimizer","by","default","if","they","have","trainable","parameters",",","and","will","have","``","train","(",")","``","\/","``","eval","(",")","``","called","on","them",".","opt_class",":","torch.optim","class","A","torch","optimizer","constructor","that","takes","only","the","list","of","parameters","(","e.g",".","a","lambda","or","partial","function","definition",")",".","By","default",",","this","will","be","passed","all","modules","in","``","modules","``","at","the","beginning","of","the","``","fit","(",")","``","method",".","This","behavior","can","be","changed","by","overriding","the","``","configure_optimizers","(",")","``","method",".","hparams",":","dict","Each","key",":","value","pair","should","consist","of","a","string","key","and","a","hyperparameter","that","is","used","within","the","overridden","methods",".","These","will","be","accessible","via","an","``","hparams","``","attribute",",","using","``","dot","''","notation",":","e.g.",",","self.hparams.model","(","x",")",".","run_opts",":","dict","A","set","of","options","to","change","the","runtime","environment","."]
docstr: Saves information from a single batch to the log
  
  Arguments
  ---------
  predictions: DiffusionPredictions
      the predictions from compute_forward
docstr_tok: ["Saves","information","from","a","single","batch","to","the","log","Arguments","--","--","--","--","-","predictions",":","DiffusionPredictions","the","predictions","from","compute_forward"]
code: def log_batch(self, predictions):
      """Saves information from a single batch to the log
  
      Arguments
      ---------
      predictions: DiffusionPredictions
          the predictions from compute_forward
      """
      loss_stats = self.loss_metric.summarize()
      stats = {
          "loss": loss_stats["average"],
          "lr": self.optimizer.param_groups[0]["lr"],
      }
      stats.update(
          self.extract_dist_stats(
              self.data_dist_stats_metric, prefix="data"
          )
      )
      if self.use_done_detector:
          stats["done_loss"] = self.done_loss_metric.summarize(
              field="average"
          )
  
      if (
          self.diffusion_mode == DiffusionMode.LATENT
          and self.train_autoencoder
      ):
          stats.update(
              self.autoencoder_loss_metric.summarize(field="average")
          )
          stats[
              "laplacian_loss"
          ] = self.autoencoder_laplacian_loss_stats_metric.summarize(
              field="average"
          )
          stats["weighted_laplacian_loss"] = (
              self.hparams.loss_laplacian_weight
              * stats["laplacian_loss"]
          )
          stats[
              "lr_autoencoder"
          ] = self.autoencoder_optimizer.param_groups[0]["lr"]
          stats.update(
              self.extract_dist_stats(
                  self.autoencoder_rec_dist_stats_metric,
                  prefix="autoencoder_rec",
              )
          )
          stats.update(
              self.extract_dist_stats(
                  self.autoencoder_latent_dist_stats_metric,
                  prefix="autoencoder_latent",
              )
          )
  
      self.hparams.tensorboard_train_logger.log_stats(
          stats_meta={"step": self.step}, train_stats=stats
      )
      if (
          self.diffusion_mode == DiffusionMode.LATENT
          and self.hparams.enable_reconstruction_sample
      ):
          self.hparams.tensorboard_train_logger.log_figure(
              f"train_ref_spectrogram", predictions.feats[0]
          )
          self.hparams.tensorboard_train_logger.log_figure(
              f"train_rec_spectrogram",
              predictions.autoencoder_output.rec[0],
          )
          latent = predictions.autoencoder_output.latent[0]
          latent = latent.view(
              latent.size(0) * latent.size(1), latent.size(2)
          )
          self.hparams.tensorboard_train_logger.log_figure(
              f"train_rec_latent", latent
          )
  
imports: import logging
  import sys
  import torch
  import speechbrain
  import os
  from collections import namedtuple
  from audiomnist_prepare import prepare_audiomnist
  from hyperpyyaml import load_hyperpyyaml
  from torchaudio import functional
  from speechbrain.dataio.dataio import length_to_mask, write_audio
  from speechbrain.dataio.dataset import apply_overfit_test
  from speechbrain.utils import data_utils
  from speechbrain.utils.train_logger import plot_spectrogram
  from enum import Enum
  from speechbrain.utils.distributed import run_on_main
  from speechbrain.utils.data_utils import dict_value_combinations, dist_stats, masked_mean, masked_min, masked_max, masked_std, match_shape
label_desc: Use image node_id 10 for calling the DiffusionBrain obj's underlying member method code with example usage: obj.log_batch(predictions) without return types