class_docstr: BoltOn Optimizer tests.
class_docstr_tok: ["BoltOn","Optimizer","tests","."]
docstr: Tests that the expected functions raise errors when not in context.
  
  Args:
      fn: the function to test
      args: the arguments for said function
      err_msg: expected error message
docstr_tok: ["Tests","that","the","expected","functions","raise","errors","when","not","in","context",".","Args",":","fn",":","the","function","to","test","args",":","the","arguments","for","said","function","err_msg",":","expected","error","message"]
code: def test_not_in_context(self, fn, args, err_msg):
      """Tests that the expected functions raise errors when not in context.
  
      Args:
          fn: the function to test
          args: the arguments for said function
          err_msg: expected error message
      """
  
      def test_run(fn, args):
          loss = TestLoss(1, 1, 1)
          bolton = opt.BoltOn(TestOptimizer(), loss)
          model = TestModel(1, (1,), 1)
          model.compile(bolton, loss)
          model.layers[0].kernel = model.layers[0].kernel_initializer(
              (model.layer_input_shape[0], model.n_outputs)
          )
          getattr(bolton, fn)(*args)
  
      with self.assertRaisesRegexp(
          Exception, err_msg
      ):  # pylint: disable=deprecated-method
          test_run(fn, args)
  
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 5 for calling the BoltonOptimizerTest obj's underlying member method code with example usage: obj.test_not_in_context(fn, args, err_msg) without return types