code: def gather(x, indices, axis, batch_dims):
      xshape = x.shape
      ishape = indices.shape
      bshape = xshape[:batch_dims]
      samples = np.prod(bshape).astype(int)
      x = x.reshape((samples,) + xshape[batch_dims:])
      indices = indices.reshape((samples,) + ishape[batch_dims:])
      y_list = []
      for b in range(samples):
          y = np.take(x[b], indices[b], axis=axis - batch_dims)
          y_list.append(y)
      y = np.stack(y_list) if samples != 1 else y_list[0]
      y = y.reshape(bshape + y.shape[1:]) if samples != 1 else y
      return y
  
imports: import pytest
  import numpy
  import nnabla.functions
  from nbla_test_utils import list_context, function_tester
label_desc: Use image node_id 1 for calling a global function with example usage: gather(x, indices, axis, batch_dims) and returns: y