class_docstr: Helper handler to log model's weights as scalars.
  Handler, upon construction, iterates over named parameters of the model and keep
  reference to ones permitted by `whitelist`. Then at every call, applies
  reduction function to each parameter, produces a scalar and logs it.
  
  Args:
      model: model to log weights
      reduction: function to reduce parameters into scalar
      tag: common title for all produced plots. For example, "generator"
      whitelist: specific weights to log. Should be list of model's submodules
          or parameters names, or a callable which gets weight along with its name
          and determines if it should be logged. Names should be fully-qualified.
          For more information please refer to `PyTorch docs
          <https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.get_submodule>`_.
          If not given, all of model's weights are logged.
  
  Examples:
      .. code-block:: python
  
          from ignite.contrib.handlers.clearml_logger import *
  
          # Create a logger
  
          clearml_logger = ClearMLLogger(
              project_name="pytorch-ignite-integration",
              task_name="cnn-mnist"
          )
  
          # Attach the logger to the trainer to log model's weights norm after each iteration
          clearml_logger.attach(
              trainer,
              event_name=Events.ITERATION_COMPLETED,
              log_handler=WeightsScalarHandler(model, reduction=torch.norm)
          )
  
      .. code-block:: python
  
          from ignite.contrib.handlers.clearml_logger import *
  
          clearml_logger = ClearMLLogger(
              project_name="pytorch-ignite-integration",
              task_name="cnn-mnist"
          )
  
          # Log only `fc` weights
          clearml_logger.attach(
              trainer,
              event_name=Events.ITERATION_COMPLETED,
              log_handler=WeightsScalarHandler(
                  model,
                  whitelist=['fc']
              )
          )
  
      .. code-block:: python
  
          from ignite.contrib.handlers.clearml_logger import *
  
          clearml_logger = ClearMLLogger(
              project_name="pytorch-ignite-integration",
              task_name="cnn-mnist"
          )
  
          # Log weights which have `bias` in their names
          def has_bias_in_name(n, p):
              return 'bias' in n
  
          clearml_logger.attach(
              trainer,
              event_name=Events.ITERATION_COMPLETED,
              log_handler=WeightsScalarHandler(model, whitelist=has_bias_in_name)
          )
  
  ..  versionchanged:: 0.4.9
      optional argument `whitelist` added.
class_docstr_tok: ["Helper","handler","to","log","model","'s","weights","as","scalars",".","Handler",",","upon","construction",",","iterates","over","named","parameters","of","the","model","and","keep","reference","to","ones","permitted","by","`","whitelist","`",".","Then","at","every","call",",","applies","reduction","function","to","each","parameter",",","produces","a","scalar","and","logs","it",".","Args",":","model",":","model","to","log","weights","reduction",":","function","to","reduce","parameters","into","scalar","tag",":","common","title","for","all","produced","plots",".","For","example",",","``","generator","''","whitelist",":","specific","weights","to","log",".","Should","be","list","of","model","'s","submodules","or","parameters","names",",","or","a","callable","which","gets","weight","along","with","its","name","and","determines","if","it","should","be","logged",".","Names","should","be","fully-qualified",".","For","more","information","please","refer","to","`","PyTorch","docs","<","https",":","\/\/pytorch.org\/docs\/stable\/generated\/torch.nn.Module.html","#","torch.nn.Module.get_submodule",">","`","_",".","If","not","given",",","all","of","model","'s","weights","are","logged",".","Examples",":","..","code-block",":",":","python","from","ignite.contrib.handlers.clearml_logger","import","*","#","Create","a","logger","clearml_logger","=","ClearMLLogger","(","project_name=","''","pytorch-ignite-integration","''",",","task_name=","''","cnn-mnist","''",")","#","Attach","the","logger","to","the","trainer","to","log","model","'s","weights","norm","after","each","iteration","clearml_logger.attach","(","trainer",",","event_name=Events.ITERATION_COMPLETED",",","log_handler=WeightsScalarHandler","(","model",",","reduction=torch.norm",")",")","..","code-block",":",":","python","from","ignite.contrib.handlers.clearml_logger","import","*","clearml_logger","=","ClearMLLogger","(","project_name=","''","pytorch-ignite-integration","''",",","task_name=","''","cnn-mnist","''",")","#","Log","only","`","fc","`","weights","clearml_logger.attach","(","trainer",",","event_name=Events.ITERATION_COMPLETED",",","log_handler=WeightsScalarHandler","(","model",",","whitelist=","[","'fc","'","]",")",")","..","code-block",":",":","python","from","ignite.contrib.handlers.clearml_logger","import","*","clearml_logger","=","ClearMLLogger","(","project_name=","''","pytorch-ignite-integration","''",",","task_name=","''","cnn-mnist","''",")","#","Log","weights","which","have","`","bias","`","in","their","names","def","has_bias_in_name","(","n",",","p",")",":","return","'bias","'","in","n","clearml_logger.attach","(","trainer",",","event_name=Events.ITERATION_COMPLETED",",","log_handler=WeightsScalarHandler","(","model",",","whitelist=has_bias_in_name",")",")","..","versionchanged",":",":","0.4.9","optional","argument","`","whitelist","`","added","."]
code: def __call__(
      self,
      engine: Engine,
      logger: ClearMLLogger,
      event_name: Union[str, Events],
  ) -> None:
      if not isinstance(logger, ClearMLLogger):
          raise RuntimeError(
              "Handler WeightsScalarHandler works only with ClearMLLogger"
          )
  
      global_step = engine.state.get_event_attrib_value(event_name)
      tag_prefix = f"{self.tag}/" if self.tag else ""
      for name, p in self.weights:
          title_name, _, series_name = name.partition(".")
          logger.clearml_logger.report_scalar(
              title=f"{tag_prefix}weights_{self.reduction.__name__}/{title_name}",
              series=series_name,
              value=self.reduction(p.data),
              iteration=global_step,
          )
  
imports: import os
  import tempfile
  import warnings
  from collections import defaultdict
  from datetime import datetime
  from enum import Enum
  from typing import Any, Callable, DefaultDict, List, Mapping, Optional, Tuple, Type, Union
  from torch.optim import Optimizer
  import ignite.distributed
  from ignite.contrib.handlers.base_logger import BaseLogger, BaseOptimizerParamsHandler, BaseOutputHandler, BaseWeightsHandler, BaseWeightsScalarHandler
  from ignite.engine import Engine, Events
  from ignite.handlers import global_step_from_engine
  from ignite.handlers.checkpoint import DiskSaver
label_desc: Use image node_id 1 for calling the WeightsScalarHandler obj's underlying member method code with example usage: obj.__call__(engine, logger, event_name) without return types