code: def gather_nd_helper(params, indices):
      indices_shape = indices.shape
      params_shape = params.shape
      if len(indices.shape) == 0:
          num_index_dims = 1
      else:
          num_index_dims = indices_shape[-1]
      result_dim_sizes_list = [
          _reduce(mul, params_shape[i + 1 :], 1)
          for i in range(len(params_shape) - 1)
      ] + [1]
      result_dim_sizes = torch.tensor(result_dim_sizes_list)
      implicit_indices_factor = int(
          result_dim_sizes[num_index_dims - 1].item()
      )
      flat_params = torch.reshape(params, (-1,))
      new_shape = [1] * (len(indices_shape) - 1) + [num_index_dims]
      indices_scales = torch.reshape(
          result_dim_sizes[0:num_index_dims], new_shape
      )
      indices_for_flat_tiled = torch.reshape(
          torch.sum(indices * indices_scales, -1, keepdim=True), (-1, 1)
      ).repeat(*[1, implicit_indices_factor])
      implicit_indices = torch.unsqueeze(
          torch.arange(implicit_indices_factor), 0
      ).repeat(*[indices_for_flat_tiled.shape[0], 1])
      indices_for_flat = indices_for_flat_tiled + implicit_indices
      flat_indices_for_flat = torch.reshape(
          indices_for_flat, (-1,)
      ).type(torch.long)
      flat_gather = torch.gather(flat_params, 0, flat_indices_for_flat)
      res = torch.reshape(
          flat_gather,
          list(indices_shape[:-1])
          + list(params_shape[num_index_dims:]),
      )
      return res
  
imports: from functools import reduce
  from numbers import Number
  from operator import mul
  from typing import Optional, Union, Sequence, Callable, List, Tuple
  import numpy
  import torch
  import ivy
  from ivy.func_wrapper import with_unsupported_dtypes, _update_torch_views
  from .None import backend_version, is_variable
  from ...ivy.general import _broadcast_to
label_desc: Use image node_id 13 for calling a global function with example usage: gather_nd_helper(params, indices) and returns: res