code: def setUp(self):
      self.tracker = WeightsGradientsStatsTracker(number_layers=2)
  
      self.absolute_min_both_layer = 0.00
      self.layer_1_min = -0.15
      self.layer_1_max = 0.24
      self.layer_1_gradients = torch.Tensor(
          [
              [self.layer_1_max],
              [self.absolute_min_both_layer],
              [self.layer_1_min],
          ]
      )
  
      self.layer_2_min = -0.25
      self.layer_2_max = 0.16
      self.layer_2_gradients = torch.Tensor(
          [
              [self.layer_2_max],
              [self.layer_2_min],
              [self.absolute_min_both_layer],
          ]
      )
  
      self.layer_1_name = "fake_name_1"
      self.layer_2_name = "fake_name_2"
      self.layer_names = [self.layer_1_name, self.layer_2_name]
  
      # The value have been compute manual according to the Welford's online algorithm
      # https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm
      # We refer to the WelfordCompute document in tests/framework/callbacks for the expected value computation.
      mean_1 = 0.13
      mean_2 = 0.1366666
      s2_1 = 0
      s2_2 = 0
      self.first_batch_expected_stats = {
          self.layer_1_name: {
              "mean": mean_1,
              "mean_std_dev_up": mean_1 + math.sqrt(s2_1),
              "mean_std_dev_down": mean_1 - math.sqrt(s2_1),
              "min": self.layer_1_min,
              "abs_min": self.absolute_min_both_layer,
              "max": self.layer_1_max,
              "abs_max": self.layer_1_max,
          },
          self.layer_2_name: {
              "mean": mean_2,
              "mean_std_dev_up": mean_2 + math.sqrt(s2_2),
              "mean_std_dev_down": mean_2 - math.sqrt(s2_2),
              "min": self.layer_2_min,
              "abs_min": self.absolute_min_both_layer,
              "max": self.layer_2_max,
              "abs_max": math.fabs(
                  self.layer_2_min
              ),  # since the absolute value is higher than the normal max
          },
      }
  
      mean_1 = 0.195
      mean_2 = 0.205
      s2_1 = 0.00845
      s2_2 = 0.0093889
      # *2 for min and max since the weights are 3 times the layers gradients
      self.second_batch_expected_stats = {
          self.layer_1_name: {
              "mean": mean_1,
              "mean_std_dev_up": mean_1 + math.sqrt(s2_1),
              "mean_std_dev_down": mean_1 - math.sqrt(s2_1),
              "min": self.layer_1_min * 2,
              "abs_min": self.absolute_min_both_layer,
              "max": self.layer_1_max * 2,
              "abs_max": self.layer_1_max * 2,
          },
          self.layer_2_name: {
              "mean": mean_2,
              "mean_std_dev_up": mean_2 + math.sqrt(s2_2),
              "mean_std_dev_down": mean_2 - math.sqrt(s2_2),
              "min": self.layer_2_min * 2,
              "abs_min": self.absolute_min_both_layer,
              "max": self.layer_2_max * 2,
              "abs_max": math.fabs(
                  self.layer_2_min * 2
              ),  # since the absolute value is higher than the normal max
          },
      }
  
      mean_1 = 0.26
      mean_2 = 0.27333333333
      s2_1 = 0.0169
      s2_2 = 0.018677778
      # *3 for min and max since the weights are 3 times the layers gradients
      self.third_batch_expected_stats = {
          self.layer_1_name: {
              "mean": mean_1,
              "mean_std_dev_up": mean_1 + math.sqrt(s2_1),
              "mean_std_dev_down": mean_1 - math.sqrt(s2_1),
              "min": self.layer_1_min * 3,
              "abs_min": self.absolute_min_both_layer,
              "max": self.layer_1_max * 3,
              "abs_max": self.layer_1_max * 3,
          },
          self.layer_2_name: {
              "mean": mean_2,
              "mean_std_dev_up": mean_2 + math.sqrt(s2_2),
              "mean_std_dev_down": mean_2 - math.sqrt(s2_2),
              "min": self.layer_2_min * 3,
              "abs_min": self.absolute_min_both_layer,
              "max": self.layer_2_max * 3,
              "abs_max": math.fabs(
                  self.layer_2_min * 3
              ),  # since the absolute value is higher than the normal max
          },
      }
  
imports: import math
  from tempfile import TemporaryDirectory
  from unittest import TestCase, skipIf
  from unittest.mock import ANY, MagicMock, call
  import torch
  import torch.nn
  from tests.framework.tools import some_data_generator
  from poutyne import GradientTracker, Model, TensorBoardGradientTracker, WeightsGradientsStatsTracker
label_desc: Use image node_id 1 for calling the GradientStatsTrackerTest obj's underlying member method code with example usage: obj.setUp() without return types