code: def ddp_init_group(run_opts):
      """This function will initialize the ddp group if
      distributed_launch bool is given in the python command line.
  
      The ddp group will use distributed_backend arg for setting the
      DDP communication protocol. `RANK` Unix variable will be used for
      registering the subprocess to the ddp group.
  
      Arguments
      ---------
      run_opts: list
          A list of arguments to parse, most often from `sys.argv[1:]`.
      """
      rank = os.environ.get("RANK")
      local_rank = os.environ.get("LOCAL_RANK")
      if local_rank is None or rank is None:
          return
  
      local_rank = int(local_rank)
      if not run_opts["distributed_backend"] == "gloo":
          if local_rank + 1 > torch.cuda.device_count():
              raise ValueError(
                  "Killing process " + str() + "\n"
                  "Not enough GPUs available!"
              )
      rank = int(rank)
  
      if run_opts["distributed_backend"] == "nccl":
          if not torch.distributed.is_nccl_available():
              raise ValueError("NCCL is not supported in your machine.")
      elif run_opts["distributed_backend"] == "gloo":
          if not torch.distributed.is_gloo_available():
              raise ValueError("GLOO is not supported in your machine.")
      elif run_opts["distributed_backend"] == "mpi":
          if not torch.distributed.is_mpi_available():
              raise ValueError("MPI is not supported in your machine.")
      else:
          raise ValueError(
              run_opts["distributed_backend"]
              + " communcation protocol doesn't exist."
          )
  
      # rank arg is used to set the right rank of the current process for ddp.
      # if you have 2 servers with 2 gpu:
      # server1:
      #   GPU0: local_rank=device=0, rank=0
      #   GPU1: local_rank=device=1, rank=1
      # server2:
      #   GPU0: local_rank=device=0, rank=2
      #   GPU1: local_rank=device=1, rank=3
      torch.distributed.init_process_group(
          backend=run_opts["distributed_backend"],
          rank=rank,
          timeout=datetime.timedelta(seconds=7200),
      )
  
file_path: speechbrain/speechbrain/utils/distributed.py
imports: import datetime
  import os
  import torch
  from functools import wraps
label_desc: Use image node_id 5 for calling a global function with example usage: ddp_init_group(run_opts) without return types