code: def parallel_checkpoint(rank, world_size, tmpdir):
      import os
      from speechbrain.utils.checkpoints import Checkpointer
  
      os.environ["RANK"] = str(rank)
      os.environ["LOCAL_RANK"] = str(rank)
  
      # initialize the process group
      sync_file = f"file://{tmpdir}/sync"
      torch.distributed.init_process_group(
          "gloo",
          rank=rank,
          world_size=world_size,
          init_method=sync_file,
      )
  
      model = torch.nn.Linear(10, 10, device="cpu")
      checkpointer = Checkpointer(tmpdir, recoverables={"model": model})
      ckpt = checkpointer.save_checkpoint()
  
      if rank != 0:
          assert ckpt is None
      if rank == 0:
          # Check that only a single checkpoint is saved, even in ddp
          # Second file is the DDP synchronization file
          assert len(os.listdir(tmpdir)) == 2
  
          # Check that the model is saved
          inp = torch.randn((3, 10), device="cpu")
          prev_output = model(inp)
          checkpointer.load_checkpoint(ckpt)
          assert torch.allclose(model(inp), prev_output)
  
file_path: speechbrain/tests/unittests/test_checkpoints.py
imports: import torch
  import pytest
label_desc: Use image node_id 9 for calling a global function with example usage: parallel_checkpoint(rank, world_size, tmpdir) without return types