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
      stage_stats = {"loss": stage_loss}
      if stage == sb.Stage.TRAIN:
          self.train_stats = stage_stats
      else:
          stage_stats["ACC"] = self.acc_metric.summarize()
          current_epoch = self.hparams.epoch_counter.current
          valid_search_interval = self.hparams.valid_search_interval
  
          if stage == sb.Stage.TEST:
              stage_stats["BLEU"] = self.bleu_metric.summarize("BLEU")
          elif (
              current_epoch % valid_search_interval == 0
              and stage == sb.Stage.VALID
          ):
              stage_stats["BLEU"] = self.bleu_metric.summarize("BLEU")
  
      # log stats and save checkpoint at end-of-epoch
      if stage == sb.Stage.VALID:
          current_epoch = self.hparams.epoch_counter.current
  
          # report different epoch stages according current stage
          current_epoch = self.hparams.epoch_counter.current
          if current_epoch <= self.hparams.stage_one_epochs:
              lr = self.hparams.noam_annealing.current_lr
              steps = self.hparams.noam_annealing.n_steps
              optimizer = self.optimizer.__class__.__name__
          else:
              lr = self.hparams.lr_sgd
              steps = -1
              optimizer = self.optimizer.__class__.__name__
  
          epoch_stats = {
              "epoch": epoch,
              "lr": lr,
              "steps": steps,
              "optimizer": optimizer,
          }
          self.hparams.train_logger.log_stats(
              stats_meta=epoch_stats,
              train_stats=self.train_stats,
              valid_stats=stage_stats,
          )
          self.checkpointer.save_and_keep_only(
              meta={"ACC": stage_stats["ACC"], "epoch": epoch},
              max_keys=["ACC"],
              num_to_keep=self.hparams.avg_checkpoints,
          )
  
      elif stage == sb.Stage.TEST:
          self.hparams.train_logger.log_stats(
              stats_meta={
                  "Epoch loaded": self.hparams.epoch_counter.current
              },
              test_stats=stage_stats,
          )
  
          with open(
              self.hparams.bleu_file, "a+", encoding="utf-8"
          ) as w:
              self.bleu_metric.write_stats(w)
  
          # save the averaged checkpoint at the end of the evaluation stage
          # delete the rest of the intermediate checkpoints
          # ACC is set to 1.1 so checkpointer only keeps the averaged checkpoint
          self.checkpointer.save_and_keep_only(
              meta={"ACC": 1.1, "epoch": epoch},
              max_keys=["ACC"],
              num_to_keep=1,
          )
  
file_path: speechbrain/recipes/Fisher-Callhome-Spanish/ST/transformer/train.py
imports: import sys
  import torch
  import logging
  import speechbrain
  from sacremoses import MosesDetokenizer
  from hyperpyyaml import load_hyperpyyaml
  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