code: def run(proc_id, nprocs, devices, g, data):
      # find corresponding device for my rank
      device = devices[proc_id]
      torch.cuda.set_device(device)
      # initialize process group and unpack data for sub-processes
      dist.init_process_group(
          backend="nccl",
          init_method="tcp://127.0.0.1:12345",
          world_size=nprocs,
          rank=proc_id,
      )
      (
          num_rels,
          num_classes,
          labels,
          train_idx,
          test_idx,
          target_idx,
          inv_target,
      ) = data
      labels = labels.to(device)
      inv_target = inv_target.to(device)
      # create RGCN model (distributed)
      in_size = g.num_nodes()
      model = RGCN(in_size, 16, num_classes, num_rels).to(device)
      model = DistributedDataParallel(
          model, device_ids=[device], output_device=device
      )
      # training + testing
      train(
          proc_id,
          device,
          g,
          target_idx,
          labels,
          num_classes,
          train_idx,
          inv_target,
          model,
      )
      test_sampler = MultiLayerNeighborSampler(
          [-1, -1]
      )  # -1 for sampling all neighbors
      test_loader = DataLoader(
          g,
          target_idx[test_idx],
          test_sampler,
          device=device,
          batch_size=32,
          shuffle=False,
          use_ddp=True,
      )
      loc_acc_split = evaluate(
          model, labels, num_classes, test_loader, inv_target
      ).to(device)
      dist.reduce(loc_acc_split, 0)
      if proc_id == 0:
          acc = loc_acc_split[0] / loc_acc_split[1]
          print("Test accuracy {:.4f}".format(acc))
      # cleanup process group
      dist.destroy_process_group()
  
file_path: dgl/examples/pytorch/rgcn/entity_sample_multi_gpu.py
imports: import argparse
  import os
  import dgl
  import torch
  import torch.distributed
  import torch.multiprocessing
  import torch.nn
  import torch.nn.functional
  from dgl.data.rdf import AIFBDataset, AMDataset, BGSDataset, MUTAGDataset
  from dgl.dataloading import DataLoader, MultiLayerNeighborSampler
  from dgl.nn.pytorch import RelGraphConv
  from torch.nn.parallel import DistributedDataParallel
  from torchmetrics.functional import accuracy
label_desc: Use image node_id 3 for calling a global function with example usage: run(proc_id, nprocs, devices, g, data) without return types