code: def init_distributed_training(num_gpus, shard_id):
      """
      Initialize variables needed for distributed training.
      """
      if num_gpus <= 1:
          return
      num_gpus_per_machine = num_gpus
      num_machines = dist.get_world_size() // num_gpus_per_machine
      for i in range(num_machines):
          ranks_on_i = list(
              range(
                  i * num_gpus_per_machine,
                  (i + 1) * num_gpus_per_machine,
              )
          )
          pg = dist.new_group(ranks_on_i)
          if i == shard_id:
              global _LOCAL_PROCESS_GROUP
              _LOCAL_PROCESS_GROUP = pg
  
file_path: pytorchvideo/pytorchvideo/layers/distributed.py
imports: import torch
  import torch.distributed
  from torch._C._distributed_c10d import ProcessGroup
  from torch.autograd.function import Function
label_desc: Use image node_id 3 for calling a global function with example usage: init_distributed_training(num_gpus, shard_id) without return types