code: def scatter_elements(
      data, indices, updates, axis=0, reduction="update"
  ):
      """Scatter elements from updates to corresponding indices of copied data.
  
      Data, indices, updates and output have the same shape.
      Indices can not have duplicates (if idx1 != idx2, then indices[idx1] != indices[idx2])
      if reduction == "update".
  
      .. code-block::
  
          output[indices[i][j]][j] = f(output[indices[i][j]][j], updates[i][j]) if axis = 0
          output[i][indices[i][j]] = f(output[i][indices[i][j]], updates[i][j]) if axis = 1
  
      where the update function f is determinted by the reduction.
      Five types of the function are supported: "update", "add", "mul", "min" and "max" (see below)
  
      Parameters
      ----------
      data : tvm.te.Tensor
          The source array.
  
      indices : tvm.te.Tensor
          The indices of the values to extract.
  
      updates : tvm.te.Tensor
          The updates to apply at the Indices
  
      axis : optional, int
          The axis to scatter on. It is zero by default.
  
      reduction : optional, string
          The update mode for the algorithm, either "update", "add", "mul", "mean", "min" or "max"
          If update, the update values will replace the input data
          If add, the update values will be added to the input data
          If mul, the input data will be multiplied on the update values
          If mean, the input data will be mean between the update values and the input data
          If min, there is choice of minimal between the update values and the input data
          If max, there is choice of maximal between the update values and the input data
          It is "update" by default
  
      Returns
      -------
      ret : tvm.te.Tensor
      """
      if not isinstance(axis, int):
          axis = get_const_int(axis)
  
      def update_func(dst_ptr, dst_index, update):
          dst_ptr[dst_index] = update
  
      def add_func(dst_ptr, dst_index, update):
          dst_ptr[dst_index] += update
  
      def mul_func(dst_ptr, dst_index, update):
          dst_ptr[dst_index] *= update
  
      def mean_func(dst_ptr, dst_index, update):
          dst_ptr[dst_index] = (dst_ptr[dst_index] + update) / 2
  
      def min_func(dst_ptr, dst_index, update):
          dst_ptr[dst_index] = tir.min(dst_ptr[dst_index], update)
  
      def max_func(dst_ptr, dst_index, update):
          dst_ptr[dst_index] = tir.max(dst_ptr[dst_index], update)
  
      reduce_func = None
      if reduction == "update":
          reduce_func = update_func
      elif reduction == "add":
          reduce_func = add_func
      elif reduction == "mul":
          reduce_func = mul_func
      elif reduction == "mean":
          reduce_func = mean_func
      elif reduction == "min":
          reduce_func = min_func
      elif reduction == "max":
          reduce_func = max_func
      else:
          raise NotImplementedError(
              "scatter_elements reduction not in [update, add, mul, min, max]:",
              reduction,
          )
  
      shape = data.shape
      rank = len(shape)
      cur_target_kind = str(
          tvm.target.Target.current(allow_none=False).kind
      )
      gen_scatter_elements_ir = None
      if (
          reduction == "add"
          and rank == 1
          and cur_target_kind not in ["vulkan", "metal"]
          and updates.dtype in ["int32", "float32"]
      ):
          gen_scatter_elements_ir = gen_scatter_add_1d_atomic
      else:
          gen_scatter_elements_ir = gen_ir
  
      out_buf = tir.decl_buffer(shape, data.dtype, "out_buf")
      return te.extern(
          [shape],
          [data, indices, updates],
          lambda ins, outs: gen_scatter_elements_ir(
              ins[0], ins[1], ins[2], outs[0], axis, reduce_func
          ),
          dtype=data.dtype,
          out_buffers=[out_buf],
          name="scatter_elements_cuda",
          tag="scatter_elements_cuda",
      )
  
file_path: tvm/python/tvm/topi/cuda/scatter_elements.py
imports: import tvm
  from tvm import te, tir
  from ..utils import ceil_div, get_const_int
  from ..math import cast
  from .nms import atomic_add
label_desc: Use image node_id 3 for calling a global function with example usage: scatter_elements(data, indices, updates, axis, reduction) and returns: te