code: def update_vectors_by_position(data, val, positions):
      """
      Update each batch with the given positions. Considered as a reversed process of
      "select_vectors_by_position", this is an operator similar to "add_vectors_by_position"
      that updates the results instead of adding.
  
      data[i, positions[i, j], :] = val[i, j, :]
  
      Parameters
      ----------
      data
          Input tensor of the array to be updated.
          Shape (batch_size, seq_length)
      val
          Input tensor of token ids
          Shape (batch_size, num_disp_position)
      positions
          Input tensor of the positions.
          Shape (batch_size, num_disp_position).
          For each sample in the batch, the values in this tensor must not exceed
          the length of the sequence.
  
      Returns
      -------
      out
          The updated result.
          Shape (batch_size, seq_length)
      """
      positions = positions.astype(np.int32)
      # batch_idx.shape = (batch_size, 1) as [[0], [1], [2], ...]
      batch_idx = np.expand_dims(
          npx.arange_like(positions, axis=0), axis=1
      ).astype(np.int32)
      batch_idx = batch_idx + np.zeros_like(positions)
      indices = np.stack(
          [batch_idx.reshape((-1,)), positions.reshape((-1,))]
      )
  
      out = npx.index_update(data, indices, npx.reshape(val, (-5, -4)))
      return out
  
file_path: gluon-nlp/src/gluonnlp/op.py
imports: import mxnet
  from mxnet import np, npx
  import math
  from mxnet import use_np
label_desc: Use image node_id 3 for calling a global function with example usage: update_vectors_by_position(data, val, positions) and returns: out