code: def test_update_vectors_by_position(
      batch_size,
      seq_length,
      num_sel_positions,
      feature_shape,
      update_shape,
      hybridized,
  ):
      data = mx.np.random.uniform(
          -1,
          1,
          (batch_size, seq_length) + feature_shape,
          dtype=np.float32,
      )
      val = mx.np.random.uniform(
          -1, 1, (batch_size, num_sel_positions) + update_shape
      )
      positions = mx.np.zeros(
          (batch_size, num_sel_positions), dtype=np.int32
      )
      for i in range(batch_size):
          positions[i, :] = np.random.choice(
              seq_length, num_sel_positions, replace=False
          )
  
      class Foo(gluon.HybridBlock):
          def forward(self, p_data, p_val, p_positions):
              return update_vectors_by_position(
                  p_data, p_val, p_positions
              )
  
      foo = Foo()
      if hybridized:
          foo.hybridize()
      out_mx = foo(data, val, positions)
      out_np = data.asnumpy().copy()
      out_np[
          np.expand_dims(
              np.arange(data.shape[0]).astype(np.int32), axis=1
          ),
          positions.asnumpy(),
      ] = val.asnumpy()
      assert_allclose(out_mx.asnumpy(), out_np, 1e-4, 1e-4)
  
file_path: gluon-nlp/tests/test_op.py
imports: import numpy
  from numpy.testing import assert_allclose
  import mxnet
  from mxnet import gluon
  from scipy.stats import ks_2samp
  import pytest
  from gluonnlp.op import *
label_desc: Use image node_id 3 for calling a global function with example usage: test_update_vectors_by_position(batch_size, seq_length, num_sel_positions, feature_shape, update_shape, hybridized) and returns: update_vectors_by_position