code: def all_gather(X):
      trainer_id = int(os.getenv("PADDLE_TRAINER_ID", "0"))
      trainer_num = int(os.getenv("PADDLE_TRAINERS_NUM", "1"))
      if trainer_num == 1:
          copy_X = X * 1
          copy_X.stop_gradient = True
          return copy_X
  
      Xs = []
      for i in range(trainer_num):
          copy_X = X * 1
          copy_X = L.collective._broadcast(copy_X, i, True)
          copy_X.stop_gradient = True
          Xs.append(copy_X)
  
      if len(Xs) > 1:
          Xs = L.concat(Xs, 0)
          Xs.stop_gradient = True
      else:
          Xs = Xs[0]
      return Xs
  
file_path: PGL/legacy/examples/erniesage/models/loss.py
imports: import time
  import glob
  import os
  import numpy
  import pgl
  import paddle.fluid
  import paddle.fluid.layers
label_desc: Use image node_id 1 for calling a global function with example usage: all_gather(X) and returns: Xs, copy_X