docstr: Gets called at the end of a stage.
docstr_tok: ["Gets","called","at","the","end","of","a","stage","."]
code: def on_stage_end(self, stage, stage_loss, epoch=None):
      """Gets called at the end of a stage."""
      if stage == sb.Stage.TRAIN:
          self.train_loss = stage_loss
      else:
          summary = self.valid_metrics.summarize(threshold=0.5)
  
      if stage == sb.Stage.VALID:
          old_lr, new_lr = self.hparams.lr_annealing(epoch)
          sb.nnet.schedulers.update_learning_rate(
              self.optimizer, new_lr
          )
          self.hparams.train_logger.log_stats(
              stats_meta={"epoch": epoch, "lr": old_lr},
              train_stats={"loss": self.train_loss},
              valid_stats={"loss": stage_loss, "summary": summary},
          )
          self.checkpointer.save_and_keep_only(
              meta={"loss": stage_loss, "summary": summary},
              num_to_keep=1,
              min_keys=["loss"],
              name="epoch_{}".format(epoch),
          )
  
      elif stage == sb.Stage.TEST:
          self.hparams.train_logger.log_stats(
              stats_meta={
                  "Epoch loaded": self.hparams.epoch_counter.current
              },
              test_stats={"loss": stage_loss, "summary": summary},
          )
  
file_path: speechbrain/recipes/LibriParty/VAD/train.py
imports: import sys
  import torch
  import logging
  import numpy
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.distributed import run_on_main
  from data_augment import augment_data
label_desc: Use image node_id 4 for calling the VADBrain obj's underlying member method code with example usage: obj.on_stage_end(stage, stage_loss, epoch) without return types