code: def test_weights_hist_handler_whitelist(dummy_model_factory):
      model = dummy_model_factory()
  
      wrapper = WeightsHistHandler(model, whitelist=["fc2.weight"])
      mock_logger = MagicMock(spec=TensorboardLogger)
      mock_logger.writer = MagicMock()
  
      mock_engine = MagicMock()
      mock_engine.state = State()
      mock_engine.state.epoch = 5
  
      wrapper(mock_engine, mock_logger, Events.EPOCH_STARTED)
      mock_logger.writer.add_histogram.assert_called_once_with(
          tag="weights/fc2/weight", values=ANY, global_step=5
      )
      mock_logger.writer.reset_mock()
  
      wrapper = WeightsHistHandler(
          model, tag="model", whitelist=["fc1"]
      )
      wrapper(mock_engine, mock_logger, Events.EPOCH_STARTED)
  
      mock_logger.writer.add_histogram.assert_has_calls(
          [
              call(
                  tag="model/weights/fc1/weight",
                  values=ANY,
                  global_step=5,
              ),
              call(
                  tag="model/weights/fc1/bias",
                  values=ANY,
                  global_step=5,
              ),
          ],
          any_order=True,
      )
      assert mock_logger.writer.add_histogram.call_count == 2
      mock_logger.writer.reset_mock()
  
      def weight_selector(n, _):
          return "bias" in n
  
      wrapper = WeightsHistHandler(
          model, tag="model", whitelist=weight_selector
      )
      wrapper(mock_engine, mock_logger, Events.EPOCH_STARTED)
  
      mock_logger.writer.add_histogram.assert_has_calls(
          [
              call(
                  tag="model/weights/fc1/bias",
                  values=ANY,
                  global_step=5,
              ),
              call(
                  tag="model/weights/fc2/bias",
                  values=ANY,
                  global_step=5,
              ),
          ],
          any_order=True,
      )
      assert mock_logger.writer.add_histogram.call_count == 2
  
imports: import math
  import os
  from unittest.mock import ANY, call, MagicMock, patch
  import pytest
  import torch
  from ignite.contrib.handlers.tensorboard_logger import global_step_from_engine, GradsHistHandler, GradsScalarHandler, OptimizerParamsHandler, OutputHandler, TensorboardLogger, WeightsHistHandler, WeightsScalarHandler
  from ignite.engine import Engine, Events, State
label_desc: Use image node_id 16 for calling a global function with example usage: test_weights_hist_handler_whitelist(dummy_model_factory) and returns: unknown