code: def test_grads_scalar_handler(dummy_model_factory, norm_mock):
      model = dummy_model_factory(
          with_grads=True, with_frozen_layer=False
      )
  
      # define test wrapper to test with and without optional tag
      def _test(tag=None):
          wrapper = GradsScalarHandler(
              model, reduction=norm_mock, tag=tag
          )
          logger = NeptuneLogger(
              project="tests/dry-run",
              mode="debug",
          )
          mock_engine = MagicMock()
          mock_engine.state = State()
          mock_engine.state.epoch = 5
          norm_mock.reset_mock()
  
          wrapper(mock_engine, logger, Events.EPOCH_STARTED)
  
          tag_prefix = f"{tag}/" if tag else ""
  
          assert logger.exists(tag_prefix + "grads_norm/fc1/weight")
          assert logger.exists(tag_prefix + "grads_norm/fc1/bias")
          assert logger.exists(tag_prefix + "grads_norm/fc2/weight")
          assert logger.exists(tag_prefix + "grads_norm/fc2/bias")
  
          logger.stop()
  
      _test()
      _test(tag="tag")
  
imports: import math
  import warnings
  from unittest.mock import MagicMock
  import pytest
  import torch
  from ignite.contrib.handlers.neptune_logger import global_step_from_engine, GradsScalarHandler, NeptuneLogger, NeptuneSaver, OptimizerParamsHandler, OutputHandler, WeightsScalarHandler
  from ignite.engine import Engine, Events, State
label_desc: Use image node_id 16 for calling a global function with example usage: test_grads_scalar_handler(dummy_model_factory, norm_mock) without return types