code: def get_rank_0_in_comm(comm):
      world_size = dist.get_world_size(comm)
      x = torch.tensor(
          [dist.get_rank()], dtype=torch.int64, device="cuda"
      )
      ys = [torch.empty_like(x) for _ in range(world_size)]
      dist.all_gather(ys, x, group=comm)
      root_rank = ys[0].item()
      return root_rank
  
label_desc: Use image node_id 2 for calling a global function with example usage: get_rank_0_in_comm(comm) and returns: root_rank