class_docstr: Helper handler to log model's gradients as histograms.
  
  Args:
      model: model to log weights
      tag: common title for all produced plots. For example, 'generator'
      whitelist: specific gradients 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 its gradient 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 gradients 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=GradsHistHandler(model)
          )
  
      .. code-block:: python
  
          from ignite.contrib.handlers.clearml_logger import *
  
          clearml_logger = ClearMLLogger(
              project_name="pytorch-ignite-integration",
              task_name="cnn-mnist"
          )
  
          # Log gradient of `fc.bias`
          clearml_logger.attach(
              trainer,
              event_name=Events.ITERATION_COMPLETED,
              log_handler=GradsHistHandler(model, whitelist=['fc.bias'])
          )
  
      .. code-block:: python
  
          from ignite.contrib.handlers.clearml_logger import *
  
          clearml_logger = ClearMLLogger(
              project_name="pytorch-ignite-integration",
              task_name="cnn-mnist"
          )
  
          # Log gradient of weights which have shape (2, 1)
          def has_shape_2_1(n, p):
              return p.shape == (2,1)
  
          clearml_logger.attach(
              trainer,
              event_name=Events.ITERATION_COMPLETED,
              log_handler=GradsHistHandler(model, whitelist=has_shape_2_1)
          )
  
  ..  versionchanged:: 0.4.9
          optional argument `whitelist` added.
class_docstr_tok: ["Helper","handler","to","log","model","'s","gradients","as","histograms",".","Args",":","model",":","model","to","log","weights","tag",":","common","title","for","all","produced","plots",".","For","example",",","'generator'","whitelist",":","specific","gradients","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","its","gradient","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","gradients","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=GradsHistHandler","(","model",")",")","..","code-block",":",":","python","from","ignite.contrib.handlers.clearml_logger","import","*","clearml_logger","=","ClearMLLogger","(","project_name=","''","pytorch-ignite-integration","''",",","task_name=","''","cnn-mnist","''",")","#","Log","gradient","of","`","fc.bias","`","clearml_logger.attach","(","trainer",",","event_name=Events.ITERATION_COMPLETED",",","log_handler=GradsHistHandler","(","model",",","whitelist=","[","'fc.bias","'","]",")",")","..","code-block",":",":","python","from","ignite.contrib.handlers.clearml_logger","import","*","clearml_logger","=","ClearMLLogger","(","project_name=","''","pytorch-ignite-integration","''",",","task_name=","''","cnn-mnist","''",")","#","Log","gradient","of","weights","which","have","shape","(","2",",","1",")","def","has_shape_2_1","(","n",",","p",")",":","return","p.shape","==","(","2,1",")","clearml_logger.attach","(","trainer",",","event_name=Events.ITERATION_COMPLETED",",","log_handler=GradsHistHandler","(","model",",","whitelist=has_shape_2_1",")",")","..","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 'GradsHistHandler' 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:
          if p.grad is None:
              continue
  
          title_name, _, series_name = name.partition(".")
          logger.grad_helper.add_histogram(
              title=f"{tag_prefix}grads_{title_name}",
              series=series_name,
              step=global_step,
              hist_data=p.grad.cpu().numpy(),
          )
  
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 GradsHistHandler obj's underlying member method code with example usage: obj.__call__(engine, logger, event_name) without return types