code: def gather(
      params: paddle.Tensor,
      indices: paddle.Tensor,
      /,
      *,
      axis: Optional[int] = -1,
      batch_dims: Optional[int] = 0,
      out: Optional[paddle.Tensor] = None,
  ) -> paddle.Tensor:
      def _gather(params1):
          if batch_dims == 0:
              result = paddle.gather(
                  params1,
                  paddle_backend.reshape(indices, shape=[-1]),
                  axis=axis,
              )
          # inputs are unstacked batch_dims times
          # because paddle.gather does not support batch_dims
          else:
              params1_list = paddle_backend.unstack(params1, axis=0)
              indices_list = paddle_backend.unstack(indices, axis=0)
              for b in range(1, batch_dims):
                  params1_list = [
                      p2
                      for p1 in params1_list
                      for p2 in paddle_backend.unstack(p1, axis=0)
                  ]
                  indices_list = [
                      i2
                      for i1 in indices_list
                      for i2 in paddle_backend.unstack(i1, axis=0)
                  ]
              result = []
              for p, i in zip(params1_list, indices_list):
                  result.append(
                      paddle.gather(
                          p,
                          paddle_backend.reshape(i, shape=[-1]),
                          axis=axis - batch_dims,
                      )
                  )
              result = paddle_backend.concat(result, axis=0)
          new_shape = (
              params1.shape[:axis]
              + indices.shape[batch_dims:]
              + params1.shape[axis + 1 :]
          )
          return paddle_backend.reshape(result, shape=new_shape)
  
      if axis is not None:
          axis = axis % params.ndim
      if batch_dims is not None:
          batch_dims = batch_dims % params.ndim
      ivy.utils.assertions.check_gather_input_valid(
          params, indices, axis, batch_dims
      )
      if params.dtype in [
          paddle.int8,
          paddle.int16,
          paddle.float16,
          paddle.complex64,
          paddle.complex128,
          paddle.bool,
      ]:
          if paddle.is_complex(params):
              return paddle.complex(
                  _gather(params.real()), _gather(params.imag())
              )
          return _gather(params.cast("float32")).cast(params.dtype)
      return _gather(params)
  
imports: from numbers import Number
  from typing import Optional, Union, Sequence, Callable, List, Tuple
  import paddle
  import numpy
  import multiprocessing
  import ivy
  import ivy.functional.backends.paddle
  from ivy.func_wrapper import with_unsupported_device_and_dtypes
  from ivy.functional.ivy.general import _broadcast_to
  from ivy.utils.exceptions import _check_inplace_update_support
  from .None import backend_version
label_desc: Use image node_id 11 for calling a global function with example usage: gather() and returns: _gather, paddle_backend, _gather, paddle