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:
          # check that all IDs are unique; no duplicate IDs
          batched_ids = sorted(list(itertools.chain(*self.ids_list)))
          assert batched_ids == sorted(list(set(batched_ids)))
  
          # write out to check later all IDs were visited
          if self.distributed_launch:
              with open(
                  f"tests/tmp/ddp_sorting_ids_{self.hparams.sorting}_{self.hparams.rank}",
                  "wb",
              ) as f:
                  pickle.dump(batched_ids, f)
  
file_path: speechbrain/tests/integration/sampling/example_sorting.py
imports: import os
  import torch
  import pickle
  import pathlib
  import itertools
  import speechbrain
  import torch.multiprocessing
  from hyperpyyaml import load_hyperpyyaml
label_desc: Use image node_id 4 for calling the SamplingBrain obj's underlying member method code with example usage: obj.on_stage_end(stage, stage_loss, epoch) without return types