code: def test_ddp():
      size = 2
      processes = []
      mp.set_start_method("spawn", force=True)
      os.makedirs("tests/tmp", exist_ok=True)
      for rank in range(size):
          p = mp.Process(target=ddp_recipes, args=(rank, size))
          p.start()
          processes.append(p)
  
      for p in processes:
          p.join()
          assert p.exitcode == 0
  
      # check all
      for sorting in ["random", "ascending", "descending"]:
          ids = []
          for rank in range(2):
              idf = f"tests/tmp/ddp_sorting_ids_{sorting}_{rank}"
              with open(idf, "rb") as f:
                  ids += pickle.load(f)
          assert (
              len(ids) == 100 if sorting == "random" else 99
          )  # sorted data stays within the 99; random not
          assert len(set(ids)) == 99
  
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 5 for calling a global function with example usage: test_ddp() without return types