docstr: Gets called at the end of an epoch.
docstr_tok: ["Gets","called","at","the","end","of","an","epoch","."]
code: def on_stage_end(self, stage, stage_loss, epoch):
      """Gets called at the end of an epoch."""
      # Compute/store important stats
      stage_stats = {"loss": stage_loss}
      if stage == sb.Stage.TRAIN:
          self.train_stats = stage_stats
      else:
          stage_stats["acc"] = sum(self.acc_metric) / len(
              self.acc_metric
          )
  
      # Perform end-of-iteration things, like annealing, logging, etc.
      if stage == sb.Stage.VALID:
          lr = self.hparams.noam_annealing.current_lr
          steps = self.hparams.noam_annealing.n_steps
          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"],
          )
  
      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/CommonVoice/self-supervised-learning/wav2vec2/train_hf_wav2vec2.py
imports: import sys
  import torch
  import logging
  import speechbrain
  import torchaudio
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.distributed import run_on_main
label_desc: Use image node_id 5 for calling the W2VBrain obj's underlying member method code with example usage: obj.on_stage_end(stage, stage_loss, epoch) without return types