class_docstr: Class for testing optimizers.py.
class_docstr_tok: ["Class","for","testing","optimizers.py","."]
docstr: Test weight decay which skips bias parameters.
docstr_tok: ["Test","weight","decay","which","skips","bias","parameters","."]
code: def test_sgd_with_weight_decay_skip_bias(self, weight_decay):
      """Test weight decay which skips bias parameters."""
      optimizer_config = ml_collections.ConfigDict()
      optimizer_config.optimizer = "sgd"
      optimizer_config.weight_decay = weight_decay
      optimizer_config.skip_scale_and_bias_regularization = True
      optimizer = optimizers.get_optimizer(
          optimizer_config, self.lr, self.params
      )
      optimizer_state = optimizer.init(self.params)
  
      _, grad = self.compute_gradient_fn(
          self.params, self.label_causing_loss
      )
      updates, _ = optimizer.update(grad, optimizer_state, self.params)
      updates = flax.traverse_util.flatten_dict(updates, sep="/")
  
      # Biases are unaffected by weight decay.
      self.assertAllClose(
          updates[DENSE_0_BIAS], self.expected_sgd_updates[DENSE_0_BIAS]
      )
      self.assertAllClose(
          updates[DENSE_1_BIAS], self.expected_sgd_updates[DENSE_1_BIAS]
      )
  
      # Kernels are affected by weight decay.
      self.assertAllClose(
          updates[DENSE_0_KERNEL],
          self.expected_sgd_updates[DENSE_0_KERNEL]
          - weight_decay * self.lr,
      )
      self.assertAllClose(
          updates[DENSE_1_KERNEL],
          self.expected_sgd_updates[DENSE_1_KERNEL]
          - weight_decay * self.lr,
      )
  
imports: from absl.testing import absltest
  from absl.testing import parameterized
  import flax
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  import optax
  from scenic.train_lib import optimizers
  from scenic.train_lib import train_utils
  import tensorflow
label_desc: Use image node_id 4 for calling the OptimizersTest obj's underlying member method code with example usage: obj.test_sgd_with_weight_decay_skip_bias(weight_decay) without return types