docstr: Gets called when a stage (either training, validation, test) starts.
docstr_tok: ["Gets","called","when","a","stage","(","either","training",",","validation",",","test",")","starts","."]
code: def on_stage_end(self, stage, stage_loss, epoch=None):
      "Gets called when a stage (either training, validation, test) starts."
      if stage == sb.Stage.TRAIN:
          self.train_loss = stage_loss
      if stage == sb.Stage.VALID:
          print("Epoch %d complete" % epoch)
          print("Train loss: %.2f" % self.train_loss)
          print("Valid loss: %.2f" % stage_loss)
          print("Recalculating and recording alignments...")
          self.evaluate(self.hparams.train_data)
  
file_path: speechbrain/tests/integration/ASR_alignment_viterbi/example_asr_alignment_viterbi_experiment.py
imports: import pathlib
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
label_desc: Use image node_id 3 for calling the AlignBrain obj's underlying member method code with example usage: obj.on_stage_end(stage, stage_loss, epoch) without return types