code: def read_rows(data, index):
      """Slice tensor with given index from dictionary of tensor or tensor
  
      This function helps to slice data from nested dictionary structure.
  
      Args:
          data: A dictionary of tensor or tensor
  
          index: A tensor of slicing index
  
      Returns:
          Return a dictionary of tensor or tensor.
      """
      if data is None:
          return None
      elif isinstance(data, dict):
          new_data = {}
          for key, value in data.items():
              new_data[key] = read_rows(value, index)
          return new_data
      else:
          return paddle_helper.gather(data, index)
  
file_path: PGL/legacy/pgl/utils/op.py
imports: import numpy
  import paddle.fluid
  from pgl.utils import paddle_helper
label_desc: Use image node_id 2 for calling a global function with example usage: read_rows(data, index) and returns: None, new_data, paddle_helper