class_docstr: BoltOn Optimizer tests.
class_docstr_tok: ["BoltOn","Optimizer","tests","."]
docstr: test that a fn of BoltOn optimizer is working as expected.
  
  Args:
    fn: method of Optimizer to test
    args: args to optimizer fn
    result: the expected result
    test_attr: None if the fn returns the test result. Otherwise, this is the
      attribute of BoltOn to check against result with.
docstr_tok: ["test","that","a","fn","of","BoltOn","optimizer","is","working","as","expected",".","Args",":","fn",":","method","of","Optimizer","to","test","args",":","args","to","optimizer","fn","result",":","the","expected","result","test_attr",":","None","if","the","fn","returns","the","test","result",".","Otherwise",",","this","is","the","attribute","of","BoltOn","to","check","against","result","with","."]
code: def test_fn(self, fn, args, result, test_attr):
      """test that a fn of BoltOn optimizer is working as expected.
  
      Args:
        fn: method of Optimizer to test
        args: args to optimizer fn
        result: the expected result
        test_attr: None if the fn returns the test result. Otherwise, this is the
          attribute of BoltOn to check against result with.
      """
      tf.random.set_seed(1)
      loss = TestLoss(1, 1, 1)
      bolton = opt.BoltOn(TestOptimizer(), loss)
      model = TestModel(1)
      model.layers[0].kernel = model.layers[0].kernel_initializer(
          (model.layer_input_shape[0], model.n_outputs)
      )
      bolton._is_init = True  # pylint: disable=protected-access
      bolton.layers = model.layers
      bolton.epsilon = 2
      bolton.noise_distribution = "laplace"
      bolton.n_outputs = 1
      bolton.n_samples = 1
      res = getattr(bolton, fn, None)(*args)
      if test_attr is not None:
          res = getattr(bolton, test_attr, None)
      if hasattr(res, "numpy") and hasattr(
          result, "numpy"
      ):  # both tensors/not
          res = res.numpy()
          result = result.numpy()
      self.assertEqual(res, result)
  
imports: import unittest
  from absl.testing import parameterized
  import tensorflow.compat.v1
  from tensorflow.compat.v1.python import ops
  from tensorflow.compat.v1.python.framework import test_util
  from tensorflow.compat.v1.python.keras import keras_parameterized
  from tensorflow.compat.v1.python.keras import losses
  from tensorflow.compat.v1.python.keras.initializers import constant
  from tensorflow.compat.v1.python.keras.models import Model
  from tensorflow.compat.v1.python.keras.optimizer_v2.optimizer_v2 import OptimizerV2
  from tensorflow.compat.v1.python.keras.regularizers import L1L2
  from tensorflow.compat.v1.python.platform import test
  from tensorflow_privacy.privacy.bolt_on import optimizers
  from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexMixin
label_desc: Use image node_id 1 for calling the BoltonOptimizerTest obj's underlying member method code with example usage: obj.test_fn(fn, args, result, test_attr) without return types