code: def _init_env_vars(use_gpu: bool):
      """Function sets up default environment variables for distributed training.
  
      Args:
          use_gpu: If true, set NCCL environment for GPUs
      """
      if "WORLD_SIZE" not in os.environ or "RANK" not in os.environ:
          os.environ["WORLD_SIZE"] = "1"
          os.environ["RANK"] = "0"
          os.environ["LOCAL_RANK"] = "0"
  
      if (
          "MASTER_ADDR" not in os.environ
          or "MASTER_PORT" not in os.environ
      ):
          os.environ["MASTER_ADDR"] = "localhost"
          os.environ["MASTER_PORT"] = "29500"
  
      if use_gpu:
          # From https://github.com/pytorch/elastic/blob/4175e9ec3ac346b89dab13eeca00e8f00b6daa8f/examples/imagenet/main.py#L156  # noqa B950
          # when using NCCL, on failures, surviving nodes will deadlock on NCCL ops
          # because NCCL uses a spin-lock on the device. Set this env var to enable a
          # watchdog thread that will destroy stale NCCL communicators, and
          # asynchronously handle NCCL errors and timed out collectives.
          os.environ["NCCL_ASYNC_ERROR_HANDLING"] = "1"
  
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 1 for calling a global function with example usage: _init_env_vars(use_gpu) without return types