code: def init_pg(self, backend="nccl"):
      if backend not in ["nccl", "gloo", "mpi"]:
          raise RuntimeError(f"Backend {backend} not supported!")
  
      dist.init_process_group(
          backend=backend,
          world_size=self.world_size,
          rank=self.rank,
          init_method=f"file://{self.file_name}",
      )
  
      # set device for nccl pg for collectives
      if backend == "nccl":
          torch.cuda.set_device(self.rank)
  
file_path: pytorch/torch/testing/_internal/distributed/_shard/sharded_tensor/__init__.py
imports: import sys
  from functools import wraps, partial
  import torch
  import torch.distributed
  from torch.distributed import rpc
  from torch.testing._internal.common_distributed import MultiProcessTestCase, TEST_SKIPS, tp_transports
label_desc: Use image node_id 2 for calling the ShardedTensorTestBase obj's underlying member method code with example usage: obj.init_pg(backend) without return types