code: def paddle_gather(x, dim, index):
      index_shape = index.shape
      index_flatten = index.flatten()
      if dim < 0:
          dim = len(x.shape) + dim
      nd_index = []
      for k in range(len(x.shape)):
          if k == dim:
              nd_index.append(index_flatten)
          else:
              reshape_shape = [1] * len(x.shape)
              reshape_shape[k] = x.shape[k]
              x_arange = paddle.arange(x.shape[k], dtype=index.dtype)
              x_arange = x_arange.reshape(reshape_shape)
              dim_index = paddle.expand(x_arange, index_shape).flatten()
              nd_index.append(dim_index)
      ind2 = paddle.transpose(paddle.stack(nd_index), [1, 0]).astype(
          "int64"
      )
      paddle_out = paddle.gather_nd(x, ind2).reshape(index_shape)
      return paddle_out
  
file_path: PaddleDetection/ppdet/modeling/rbox_utils.py
imports: import math
  import paddle
  import numpy
  import cv2
label_desc: Use image node_id 9 for calling a global function with example usage: paddle_gather(x, dim, index) and returns: paddle_out