class_docstr: Class for classifier training"
      
class_docstr_tok: ["Class","for","classifier","training","''"]
docstr: Gets called at the beginning of each epoch.
  
  Arguments
  ---------
  stage : sb.Stage
      One of sb.Stage.TRAIN, sb.Stage.VALID, or sb.Stage.TEST.
  epoch : int
      The currently-starting epoch. This is passed
      `None` during the test stage.
docstr_tok: ["Gets","called","at","the","beginning","of","each","epoch",".","Arguments","--","--","--","--","-","stage",":","sb.Stage","One","of","sb.Stage.TRAIN",",","sb.Stage.VALID",",","or","sb.Stage.TEST",".","epoch",":","int","The","currently-starting","epoch",".","This","is","passed","`","None","`","during","the","test","stage","."]
code: def on_stage_start(self, stage, epoch=None):
      """Gets called at the beginning of each epoch.
  
      Arguments
      ---------
      stage : sb.Stage
          One of sb.Stage.TRAIN, sb.Stage.VALID, or sb.Stage.TEST.
      epoch : int
          The currently-starting epoch. This is passed
          `None` during the test stage.
      """
      # Set up statistics trackers for this stage
      self.loss_metric = sb.utils.metric_stats.MetricStats(
          metric=sb.nnet.losses.nll_loss
      )
  
      # Compute Accuracy using MetricStats
      # Define function taking (prediction, target, length) for eval
      def accuracy_value(predict, target, lengths):
          """Computes Accuracy"""
          nbr_correct, nbr_total = sb.utils.Accuracy.Accuracy(
              predict, target, lengths
          )
          acc = torch.tensor([nbr_correct / nbr_total])
          return acc
  
      self.acc_metric = sb.utils.metric_stats.MetricStats(
          metric=accuracy_value, n_jobs=1
      )
  
      # Confusion matrices
      if stage == sb.Stage.VALID:
          self.valid_confusion_matrix = np.zeros(
              shape=(
                  self.hparams.out_n_neurons,
                  self.hparams.out_n_neurons,
              ),
              dtype=int,
          )
      if stage == sb.Stage.TEST:
          self.test_confusion_matrix = np.zeros(
              shape=(
                  self.hparams.out_n_neurons,
                  self.hparams.out_n_neurons,
              ),
              dtype=int,
          )
  
      # Set up evaluation-only statistics trackers
      if stage != sb.Stage.TRAIN:
          self.error_metrics = self.hparams.error_stats()
  
file_path: speechbrain/recipes/ESC50/classification/train_classifier.py
imports: import os
  import sys
  import torch
  import torchaudio
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.distributed import run_on_main
  from esc50_prepare import prepare_esc50
  from sklearn.metrics import confusion_matrix
  import numpy
  from confusion_matrix_fig import create_cm_fig
label_desc: Use image node_id 3 for calling the ESC50Brain obj's underlying member method code with example usage: obj.on_stage_start(stage, epoch) and returns: acc