class_docstr: Shard the feature into multi-gpu with NCCL and UVA to support large scale feature.
  
  Args:
      x: numpy array feature
      mode: use 'uva' or 'gpu' for feature storage.
  
  Usage:
  
      import paddle
  
      paddle.distributed.init_parallel_env()
  
      x = ...
  
      x = DistFeat(x, mode="gpu")
  
      batch = np.random.randint(0, 100, shape=1000)
  
      x = x[batch]
class_docstr_tok: ["Shard","the","feature","into","multi-gpu","with","NCCL","and","UVA","to","support","large","scale","feature",".","Args",":","x",":","numpy","array","feature","mode",":","use","'uva","'","or","'gpu","'","for","feature","storage",".","Usage",":","import","paddle","paddle.distributed.init_parallel_env","(",")","x","=","...","x","=","DistFeat","(","x",",","mode=","''","gpu","''",")","batch","=","np.random.randint","(","0",",","100",",","shape=1000",")","x","=","x","[","batch","]"]
code: def __init__(self, x, mode="uva"):
      self.rank = paddle.distributed.get_rank()
      self.nrank = paddle.distributed.get_world_size()
      self.part = x.shape[1] // self.nrank
      self.mode = mode
  
      if mode == "cpu":
          self.x = x
      elif mode == "uva":
          x = x[:, self.rank * self.part : (self.rank + 1) * self.part]
          x = self.to_contiguousarray(x)
          self.x = core.eager.to_uva_tensor(x, 0)
      elif mode == "gpu":
          x = x[:, self.rank * self.part : (self.rank + 1) * self.part]
          self.x = paddle.to_tensor(x, dtype=x.dtype)
  
file_path: PGL/examples/NeurIPS2022-OGB-Challenge/MAG240M/dist_feat.py
imports: import os
  import numpy
  import paddle
  from paddle.framework import core
label_desc: Use image node_id 1 to create a new DistFeat object from inherited base classes: object with example: obj = DistFeat(x, mode)