code: def test_trainer_with_sparse_grad_on_single_context():
      x = gluon.Parameter("x", shape=(10,), grad_stype="row_sparse")
      x.initialize(ctx=[mx.cpu(0)], init="zeros")
      trainer = gluon.Trainer(
          [x], "sgd", {"learning_rate": 1.0, "momentum": 0.5}
      )
      with mx.autograd.record():
          for w in x.list_data():
              y = w + 1
              y.backward()
      trainer.step(1)
  
      assert trainer._update_on_kvstore is None
      assert (
          trainer._kvstore is None
      )  # No kvstore created for single-device training
      assert (x.data(mx.cpu(0)).asnumpy() == -1).all()
  
imports: import mxnet
  import unittest
  import os
  import numpy
  from mxnet import gluon
  from mxnet.gluon import nn
  from mxnet.test_utils import assert_almost_equal
  from common import assertRaises, xfail_when_nonstandard_decimal_separator
  from copy import deepcopy
  import pytest
label_desc: Use image node_id 3 for calling a global function with example usage: test_trainer_with_sparse_grad_on_single_context() without return types