docstr: Gets called at the beginning of each epoch
docstr_tok: ["Gets","called","at","the","beginning","of","each","epoch"]
code: def on_stage_start(self, stage, epoch):
      """Gets called at the beginning of each epoch"""
      if stage != sb.Stage.TRAIN:
          # Define function taking (prediction, target) for parallel eval
          def pesq_eval(pred_wav, target_wav):
              """Computes the PESQ evaluation metric"""
              psq_mode = (
                  "wb"
                  if self.hparams.enhance_sample_rate == 16000
                  else "nb"
              )
              try:
                  return pesq(
                      fs=self.hparams.enhance_sample_rate,
                      ref=target_wav.numpy(),
                      deg=pred_wav.numpy(),
                      mode=psq_mode,
                  )
              except Exception:
                  print("pesq encountered an error for this data item")
                  return 0
  
          self.pesq_metric = MetricStats(
              metric=pesq_eval, n_jobs=1, batch_eval=False
          )
          self.cer_metric = self.hparams.cer_computer()
          self.wer_metric = self.hparams.error_rate_computer()
  
      # Freeze models before training
      else:
          for model in self.hparams.frozen_models:
              if (
                  hasattr(self.hparams, "unfreeze_epoch")
                  and epoch >= self.hparams.unfreeze_epoch
                  and (
                      not hasattr(self.hparams, "unfrozen_models")
                      or model in self.hparams.unfrozen_models
                  )
              ):
                  self.modules[model].train()
                  for p in self.modules[model].parameters():
                      p.requires_grad = (
                          True  # Model's weight will be updated
                      )
              else:
                  self.modules[model].eval()
                  for p in self.modules[model].parameters():
                      p.requires_grad = False
  
imports: import os
  import sys
  import csv
  import logging
  import numpy
  from tqdm import tqdm
  from pesq import pesq
  from pystoi import stoi
  import torch
  import torchaudio
  import torch.nn.functional
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.metric_stats import MetricStats
  from speechbrain.utils.distributed import run_on_main
  from speechbrain.utils.data_utils import undo_padding
label_desc: Use image node_id 7 for calling the ASR obj's underlying member method code with example usage: obj.on_stage_start(stage, epoch) and returns: pesq, int