code: def _init_distributed(use_gpu: bool):
      """Function perform distributed setup for DDP.
  
      Requires the script to be started with torch.distributed.launch
      script and uses environment variables for node finding.
  
      Args:
          use_gpu: If true, use distributed GPU training, else use CPU
      """
      distributed_world_size = int(os.environ["WORLD_SIZE"])
      distributed_rank = int(os.environ["RANK"])
      backend = "nccl" if use_gpu else "gloo"
      torch.distributed.init_process_group(
          backend=backend,
          init_method="env://",
          world_size=distributed_world_size,
          rank=distributed_rank,
      )
  
file_path: ClassyVision/classy_vision/trainer/distributed_trainer.py
imports: import logging
  import os
  import torch
  from classy_vision.generic.distributed_util import get_rank, get_world_size, set_cpu_device, set_cuda_device_index
  from .classy_trainer import ClassyTrainer
label_desc: Use image node_id 2 for calling a global function with example usage: _init_distributed(use_gpu) without return types