class_docstr: The weights' gradient statistic tracker will estimate the absolute mean (i.e. the mean of the absolute values of
  the weights' gradients), running absolute mean variance (i.e. the variance of the absolute mean), min, absolute min,
   max and absolute max per layer. The tracker is using the `Welford's online algorithm
   <https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm>`_
  to estimate the running mean and running variance of the absolute weights' gradients.
  
  Args:
      number_layers (int): The number of layers to track stats on.
class_docstr_tok: ["The","weights","'","gradient","statistic","tracker","will","estimate","the","absolute","mean","(","i.e",".","the","mean","of","the","absolute","values","of","the","weights","'","gradients",")",",","running","absolute","mean","variance","(","i.e",".","the","variance","of","the","absolute","mean",")",",","min",",","absolute","min",",","max","and","absolute","max","per","layer",".","The","tracker","is","using","the","`","Welford","'s","online","algorithm","<","https",":","\/\/en.wikipedia.org\/wiki\/Algorithms_for_calculating_variance","#","Welford's_online_algorithm",">","`","_","to","estimate","the","running","mean","and","running","variance","of","the","absolute","weights","'","gradients",".","Args",":","number_layers","(","int",")",":","The","number","of","layers","to","track","stats","on","."]
docstr: Accumulate the running absolute mean, running absolute mean variance, min, absolute min, max ant the absolute
  max for all the layers.
  
  Args:
       named_parameters (Iterable[Tuple[str, ~torch.nn.parameter.Parameter]): The named parameters of the model to
       track.
docstr_tok: ["Accumulate","the","running","absolute","mean",",","running","absolute","mean","variance",",","min",",","absolute","min",",","max","ant","the","absolute","max","for","all","the","layers",".","Args",":","named_parameters","(","Iterable","[","Tuple","[","str",",","~torch.nn.parameter.Parameter","]",")",":","The","named","parameters","of","the","model","to","track","."]
code: def batch_statistic_upgrade(
      self,
      named_parameters: Iterable[
          Tuple[str, torch.nn.parameter.Parameter]
      ],
  ) -> None:
      """
      Accumulate the running absolute mean, running absolute mean variance, min, absolute min, max ant the absolute
      max for all the layers.
  
      Args:
           named_parameters (Iterable[Tuple[str, ~torch.nn.parameter.Parameter]): The named parameters of the model to
           track.
      """
      batch_layer_abs_means = []
      batch_layer_min = []
      batch_layer_abs_min = []
      batch_layer_max = []
      batch_layer_abs_max = []
  
      # Just in case we want to support second-order derivatives
      with torch.no_grad():
          for _, layer_params in named_parameters:
              layer_gradient = layer_params.grad
  
              abs_value_layer_gradient = layer_gradient.abs()
  
              batch_layer_abs_means.append(
                  abs_value_layer_gradient.mean().cpu().numpy()
              )
  
              batch_layer_min.append(layer_gradient.min().cpu().numpy())
              batch_layer_abs_min.append(
                  abs_value_layer_gradient.min().cpu().numpy()
              )
  
              batch_layer_max.append(layer_gradient.max().cpu().numpy())
              batch_layer_abs_max.append(
                  abs_value_layer_gradient.max().cpu().numpy()
              )
  
      batch_layer_abs_means = np.array(batch_layer_abs_means)
      previous_mean = self.running_abs_mean
  
      self.running_abs_mean = (
          previous_mean
          + (batch_layer_abs_means - previous_mean) / self.count
      )
  
      self.running_m2 = self.running_m2 + (
          batch_layer_abs_means - previous_mean
      ) * (batch_layer_abs_means - self.running_abs_mean)
  
      self.running_abs_mean_var = (
          self.running_m2 / (self.count - 1)
          if self.count > 1
          else self.running_abs_mean_var
      )
  
      batch_layer_min = np.array(batch_layer_min)
      batch_layer_max = np.array(batch_layer_max)
  
      self.running_min = np.minimum(batch_layer_min, self.running_min)
      self.running_abs_min = np.minimum(
          batch_layer_abs_min, self.running_abs_min
      )
  
      self.running_max = np.maximum(batch_layer_max, self.running_max)
      self.running_abs_max = np.maximum(
          batch_layer_abs_max, self.running_abs_max
      )
  
      self.count += 1
  
imports: from typing import Dict, Iterable, List, Tuple
  import numpy
  import torch
  from poutyne.framework.callbacks.callbacks import Callback
label_desc: Use image node_id 2 for calling the WeightsGradientsStatsTracker obj's underlying member method code with example usage: obj.batch_statistic_upgrade(named_parameters) without return types