code: def test_keep_good_layer(self):
      # pylint: disable=protected-access
      gradient_tracker = GradientTracker(keep_bias=False)
      layer_to_keep_params = MagicMock()
      layer_to_keep_params.requires_grad = True
      self.assertTrue(
          gradient_tracker._keep_layer(
              layer_to_keep_params, "fake_layer_name_to_keep"
          )
      )
      self.assertFalse(
          gradient_tracker._keep_layer(
              layer_to_keep_params, "bias_name_not_to_keep"
          )
      )
  
      layer_not_to_keep_params = MagicMock()
      layer_not_to_keep_params.requires_grad = False
      self.assertFalse(
          gradient_tracker._keep_layer(
              layer_not_to_keep_params, "fake_layer_name_not_to_keep"
          )
      )
      self.assertFalse(
          gradient_tracker._keep_layer(
              layer_not_to_keep_params, "bias_name_not_to_keep"
          )
      )
  
      gradient_tracker = GradientTracker(keep_bias=True)
      layer_to_keep_params = MagicMock()
      layer_to_keep_params.requires_grad = True
      self.assertTrue(
          gradient_tracker._keep_layer(
              layer_to_keep_params, "fake_layer_name_to_keep"
          )
      )
      self.assertTrue(
          gradient_tracker._keep_layer(
              layer_to_keep_params, "bias_name_to_keep"
          )
      )
  
      layer_not_to_keep_params = MagicMock()
      layer_not_to_keep_params.requires_grad = False
      self.assertFalse(
          gradient_tracker._keep_layer(
              layer_not_to_keep_params, "fake_layer_name_not_to_keep"
          )
      )
      self.assertFalse(
          gradient_tracker._keep_layer(
              layer_not_to_keep_params, "bias_name_not_to_keep"
          )
      )
  
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 GradientTrackerTest obj's underlying member method code with example usage: obj.test_keep_good_layer() without return types