code: def gather(input, index):
      """Gather input from given index.
  
      Slicing input data with given index. This function rewrite paddle.L.gather
      to fix issue: https://github.com/PaddlePaddle/Paddle/issues/17509 when paddlepaddle's
      version is less than 1.5.
  
      Args:
          input: Input tensor to be sliced
  
          index: Slice index
  
      Return:
          A tensor that are sliced from given input data.
      """
      try:
          # PaddlePaddle 1.5
          output = L.gather(input, index, overwrite=False)
          return output
      except TypeError as e:
          warnings.warn(
              "Your paddle version is less than 1.5"
              " gather may be slower."
          )
  
          if index.dtype == core.VarDesc.VarType.INT32:
              index = L.cast(index, "int64")
              if index.shape[-1] != 1:
                  index = L.reshape(index, shape=[-1, 1])
              index.stop_gradient = True
  
          helper = layer_helper.LayerHelper(
              "gather", **locals()
          )  # **locals())
          dtype = input.dtype
          tmp = helper.create_variable_for_type_inference(dtype)
          padding_idx = -1
          helper.append_op(
              type="lookup_table",
              inputs={"Ids": index, "W": input},
              outputs={"Out": tmp},
              attrs={
                  "is_sparse": False,
                  "is_distributed": False,
                  "remote_prefetch": False,
                  "padding_idx": padding_idx,
              },
          )
          return tmp
  
file_path: PGL/legacy/pgl/utils/paddle_helper.py
imports: import warnings
  import numpy
  import paddle
  from paddle.fluid import core
  import paddle.fluid
  import paddle.fluid.layer_helper
  import paddle.fluid.layers
  from pgl.utils.logger import log
label_desc: Use image node_id 1 for calling a global function with example usage: gather(input, index) and returns: output, tmp