code: def test_kvstore(kv_type, stype):
      print(kv_type)
      kv = mx.kv.create(kv_type)
      kv.set_optimizer(mx.optimizer.create("test", learning_rate=-lr))
      for k, s in zip(keys, shapes):
          kv.init(k, mx.nd.zeros(s))
  
      res = [np.zeros(s) for s in shapes]
      for i in range(nrepeat):
          for j in range(len(keys)):
              kv.push(
                  keys[j],
                  [
                      mx.nd.array(data[i][j][g], mx.gpu(g)).tostype(
                          stype
                      )
                      for g in range(nworker)
                  ],
              )
  
          res = [
              a + b * lr for a, b in zip(res, [sum(d) for d in data[i]])
          ]
          for j in range(len(keys)):
              out = [
                  mx.nd.zeros(shapes[j], mx.gpu(g))
                  for g in range(nworker)
              ]
              kv.pull(keys[j], out=out)
              err = [np.sum(np.abs(o.asnumpy() - res[j])) for o in out]
              err = sum(err) / np.sum(np.abs(res[j]))
              assert err < 1e-6, (err, shapes[j])
  
file_path: mxnet/tests/nightly/test_kvstore.py
imports: import sys
  import mxnet
  import numpy
  import numpy.random
  import copy
  from mxnet.test_utils import assert_almost_equal
label_desc: Use image node_id 5 for calling a global function with example usage: test_kvstore(kv_type, stype) without return types