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 __getitem__(self, key):
      if self.mode != "cpu":
          key_size = paddle.shape(key)[0]
          max_key_size = self.get_max_key_size(key_size)
          batch = self.padding(key, max_key_size - key_size)
          idx = self.allgather(batch)
          tensor = self.x[idx]
          tensor = self.alltoall(tensor)
          return tensor[:key_size]
      else:
          x = self.x[key]
          return 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 4 for calling the DistFeat obj's underlying member method code with example usage: obj.__getitem__(key) and returns: tensor, paddle