docstr: Gets called at the end of a epoch.
docstr_tok: ["Gets","called","at","the","end","of","a","epoch","."]
code: def on_stage_end(self, stage, stage_loss, epoch):
      """Gets called at the end of a epoch."""
      # Compute/store important stats
      if stage == sb.Stage.TRAIN:
          self.train_stats = stage_loss
  
      else:  # valid or test
          stage_stats = {"loss": stage_loss}
          current_epoch = self.hparams.epoch_counter.current
  
      # log stats and save checkpoint at end-of-epoch
      if (
          stage == sb.Stage.VALID
          and sb.utils.distributed.if_main_process()
      ):
          current_epoch = self.hparams.epoch_counter.current
          old_lr_adam, new_lr_adam = self.hparams.lr_annealing_adam(
              stage_stats["loss"]
          )
          sb.nnet.schedulers.update_learning_rate(
              self.adam_optimizer, new_lr_adam
          )
  
          stats_meta = {
              "epoch": current_epoch,
              "lr_adam": old_lr_adam,
          }
  
          if not self.hparams.wav2vec2_frozen:
              (
                  old_lr_wav2vec,
                  new_lr_wav2vec,
              ) = self.hparams.lr_annealing_wav2vec(stage_stats["loss"])
              sb.nnet.schedulers.update_learning_rate(
                  self.wav2vec_optimizer, new_lr_wav2vec
              )
              stats_meta["lr_wav2vec"] = old_lr_wav2vec
  
          if not self.hparams.labse_frozen:
              (
                  old_lr_labse,
                  new_lr_labse,
              ) = self.hparams.lr_annealing_labse(stage_stats["loss"])
              sb.nnet.schedulers.update_learning_rate(
                  self.labse_optimizer, new_lr_labse
              )
              stats_meta["lr_labse"] = old_lr_labse
  
          self.hparams.train_logger.log_stats(
              stats_meta=stats_meta,
              train_stats={"loss": self.train_stats},
              valid_stats=stage_stats,
          )
  
          # create checkpoing
          meta = {"loss": stage_stats["loss"], "epoch": current_epoch}
          name = "checkpoint_epoch" + str(current_epoch)
  
          self.checkpointer.save_and_keep_only(
              meta=meta, name=name, num_to_keep=10, min_keys=["loss"]
          )
  
      elif stage == sb.Stage.TEST:
          self.hparams.train_logger.log_stats(
              stats_meta={
                  "Epoch loaded": self.hparams.epoch_counter.current
              },
              test_stats=stage_stats,
          )
  
file_path: speechbrain/recipes/IWSLT22_lowresource/AST/transformer/train_samu.py
imports: import sys
  import torch
  import logging
  from hyperpyyaml import load_hyperpyyaml
  import speechbrain
  import torch.nn.functional
  from speechbrain.utils.distributed import run_on_main
label_desc: Use image node_id 6 for calling the ST obj's underlying member method code with example usage: obj.on_stage_end(stage, stage_loss, epoch) without return types