code: def test_weights_scalar_handler_custom_reduction():
      class DummyModel(torch.nn.Module):
          def __init__(self):
              super(DummyModel, self).__init__()
              self.fc1 = torch.nn.Linear(10, 10)
              self.fc2 = torch.nn.Linear(12, 12)
              self.fc1.weight.data.zero_()
              self.fc1.bias.data.zero_()
              self.fc2.weight.data.fill_(1.0)
              self.fc2.bias.data.fill_(1.0)
  
      model = DummyModel()
  
      def norm(x):
          return 12.34
  
      wrapper = WeightsScalarHandler(
          model, reduction=norm, show_legend=True
      )
      mock_logger = MagicMock(spec=VisdomLogger)
      mock_logger.vis = MagicMock()
      mock_logger.executor = _DummyExecutor()
  
      mock_engine = MagicMock()
      mock_engine.state = State()
      mock_engine.state.epoch = 5
  
      wrapper(mock_engine, mock_logger, Events.EPOCH_STARTED)
  
      assert mock_logger.vis.line.call_count == 4
      mock_logger.vis.line.assert_has_calls(
          [
              call(
                  X=[5],
                  Y=[12.34],
                  env=mock_logger.vis.env,
                  win=None,
                  update=None,
                  opts=wrapper.windows["weights_norm/fc1/weight"][
                      "opts"
                  ],
                  name="weights_norm/fc1/weight",
              ),
              call(
                  X=[5],
                  Y=[12.34],
                  env=mock_logger.vis.env,
                  win=None,
                  update=None,
                  opts=wrapper.windows["weights_norm/fc1/bias"]["opts"],
                  name="weights_norm/fc1/bias",
              ),
              call(
                  X=[5],
                  Y=[12.34],
                  env=mock_logger.vis.env,
                  win=None,
                  update=None,
                  opts=wrapper.windows["weights_norm/fc2/weight"][
                      "opts"
                  ],
                  name="weights_norm/fc2/weight",
              ),
              call(
                  X=[5],
                  Y=[12.34],
                  env=mock_logger.vis.env,
                  win=None,
                  update=None,
                  opts=wrapper.windows["weights_norm/fc2/bias"]["opts"],
                  name="weights_norm/fc2/bias",
              ),
          ],
          any_order=True,
      )
  
imports: import sys
  from unittest.mock import ANY, call, MagicMock, patch
  import pytest
  import torch
  from ignite.contrib.handlers.visdom_logger import _DummyExecutor, global_step_from_engine, GradsScalarHandler, OptimizerParamsHandler, OutputHandler, VisdomLogger, WeightsScalarHandler
  from ignite.engine import Engine, Events, State
label_desc: Use image node_id 13 for calling a global function with example usage: test_weights_scalar_handler_custom_reduction() and returns: int