code: def gather(input, dim, index, *, sparse_grad=False, out=None):
      if sparse_grad:
          raise ivy.utils.exceptions.IvyException(
              "Gather does not yet support the sparse grad functionality"
          )
  
      dim = dim % len(input.shape)
      all_indices = ivy.argwhere(ivy.full(index.shape, True))
      gather_locations = ivy.reshape(
          index, [ivy.prod(ivy.array(index.shape))]
      )
  
      gather_indices = []
      for axis in range(len(index.shape)):
          if axis == dim:
              gather_indices.append(
                  ivy.array(gather_locations, dtype=index.dtype)
              )
          else:
              gather_indices.append(
                  ivy.array(all_indices[:, axis], dtype=index.dtype)
              )
  
      gather_indices = ivy.stack(gather_indices, axis=-1)
      gathered = ivy.gather_nd(input, gather_indices)
      reshaped = ivy.reshape(gathered, index.shape)
      return reshaped
  
imports: import ivy
  from ivy.func_wrapper import with_unsupported_dtypes
  from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back, numpy_to_torch_style_args, to_ivy_shape
  import ivy.functional.frontends.torch
label_desc: Use image node_id 11 for calling a global function with example usage: gather(input, dim, index) and returns: reshaped