class_docstr: Tests for LBFGS optimization algorithm.
class_docstr_tok: ["Tests","for","LBFGS","optimization","algorithm","."]
docstr: Stops gently when encountering a -inf objective.
docstr_tok: ["Stops","gently","when","encountering","a","-inf","objective","."]
code: def test_stop_at_negative_infinity(self, start):
      """Stops gently when encountering a -inf objective."""
      minimum = np.array([1.0, 1.0])
      scales = np.array([2.0, 3.0])
  
      @_make_val_and_grad_fn
      def quadratic_with_hole(x):
          quadratic = tf.reduce_sum(
              scales * tf.math.squared_difference(x, minimum), axis=-1
          )
          square_hole = tf.reduce_all(
              tf.logical_and((x > 0.7), (x < 1.3)), axis=-1
          )
          minus_infty = tf.constant(
              float("-inf"), dtype=quadratic.dtype
          )
          answer = tf.where(square_hole, minus_infty, quadratic)
          return answer
  
      start = tf.constant(start)
      results = self.evaluate(
          lbfgs.minimize(
              quadratic_with_hole,
              initial_position=start,
              tolerance=1e-8,
          )
      )
      self.assertAllTrue(results.converged)
      self.assertAllFalse(results.failed)
      self.assertAllNegativeInf(results.objective_value)
      self.assertAllFinite(results.position)
      self.assertAllNegativeInf(
          quadratic_with_hole(results.position)[0]
      )
  
imports: from absl.testing import parameterized
  import numpy
  from scipy.stats import special_ortho_group
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.optimizer import bfgs_utils
  from tensorflow_probability.python.optimizer import lbfgs
label_desc: Use image node_id 17 for calling the LBfgsTest obj's underlying member method code with example usage: obj.test_stop_at_negative_infinity(start) and returns: answer