code: def scatter_nd(
      indices: np.ndarray,
      updates: np.ndarray,
      /,
      shape: Optional[Union[ivy.NativeShape, Sequence[int]]] = None,
      *,
      reduction: str = "sum",
      out: Optional[np.ndarray] = None,
  ) -> np.ndarray:
      target = out
      target_given = ivy.exists(target)
      if ivy.exists(shape) and target_given:
          ivy.utils.assertions.check_equal(
              ivy.Shape(target.shape), ivy.Shape(shape), as_array=False
          )
      indices_flat = indices.reshape(-1, indices.shape[-1]).T
      indices_tuple = tuple(indices_flat) + (Ellipsis,)
      if not target_given:
          shape = list(shape) if ivy.exists(shape) else list(out.shape)
          target = np.zeros(shape, dtype=updates.dtype)
      updates = _broadcast_to(updates, target[indices_tuple].shape)
      if reduction == "sum":
          np.add.at(target, indices_tuple, updates)
      elif reduction == "replace":
          target = np.asarray(target).copy()
          target.setflags(write=1)
          target[indices_tuple] = updates
      elif reduction == "min":
          np.minimum.at(target, indices_tuple, updates)
      elif reduction == "max":
          np.maximum.at(target, indices_tuple, updates)
      elif reduction == "mul":
          np.multiply.at(target, indices_tuple, updates)
      else:
          raise ivy.utils.exceptions.IvyException(
              f'reduction is {reduction}, but it must be one of "sum", "min", "max",'
              ' "mul" or "replace"'
          )
      if ivy.exists(out):
          return ivy.inplace_update(out, target)
      return target
  
imports: from typing import Optional, Union, Sequence, Callable, Tuple
  import numpy
  from operator import mul
  from functools import reduce
  import multiprocessing
  from numbers import Number
  import ivy
  from ivy.functional.backends.numpy.helpers import _scalar_output_to_0d_array
  from ivy.func_wrapper import with_unsupported_dtypes
  from .None import backend_version
  from ...ivy.general import _broadcast_to
label_desc: Use image node_id 21 for calling a global function with example usage: scatter_nd(shape) and returns: target, ivy