code: def test_solver_zeroing():
      xs = [nn.Variable([2, 3, 4], need_grad=True) for _ in range(3)]
  
      s = S.Sgd(1)
      s.set_parameters({str(i): x for i, x in enumerate(xs)})
  
      for x in xs:
          x.data.fill(1)
          x.grad.zero()
  
      s.weight_decay(1.0)
      s.update()
      for x in xs:
          # Grad is not referenced since neither weight decay nor update is performed.
          assert x.grad.zeroing
          assert_allclose(x.d, 1)
  
      for x in xs:
          x.grad.fill(1)
  
      s.weight_decay(0.1)
      s.update()
  
      for x in xs:
          assert_allclose(x.d, 1 - (1 + 0.1))
  
file_path: nnabla/python/test/solver/test_solver.py
imports: import pytest
  import nnabla
  import nnabla.solvers
  import numpy
  from solver_test_utils import solver_tester, RefSolver
  from nbla_test_utils import list_context
  from nnabla.testing import assert_allclose
label_desc: Use image node_id 1 for calling a global function with example usage: test_solver_zeroing() without return types