class_docstr: Tests for BFGS optimization algorithm.
class_docstr_tok: ["Tests","for","BFGS","optimization","algorithm","."]
docstr: Can build a bfgs_op with dynamic shapes in graph mode.
docstr_tok: ["Can","build","a","bfgs_op","with","dynamic","shapes","in","graph","mode","."]
code: def test_dynamic_shapes(self):
      """Can build a bfgs_op with dynamic shapes in graph mode."""
      if tf.executing_eagerly():
          return
      minimum = np.array([1.0, 1.0])
      scales = np.array([2.0, 3.0])
  
      @_make_val_and_grad_fn
      def quadratic(x):
          return tf.reduce_sum(
              scales * tf.math.squared_difference(x, minimum), axis=-1
          )
  
      # Test with a vector of unknown dimension, and a fully unknown shape.
      for shape in ([None], None):
          start = tf1.placeholder_with_default([0.6, 0.8], shape=shape)
          bfgs_op = bfgs.minimize(
              quadratic, initial_position=start, tolerance=1e-8
          )
          self.assertFalse(bfgs_op.position.shape.is_fully_defined())
  
          results = self.evaluate(bfgs_op)
          self.assertTrue(results.converged)
          self.assertLessEqual(_norm(results.objective_gradient), 1e-8)
          self.assertArrayNear(results.position, minimum, 1e-5)
  
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
  from tensorflow_probability.python.optimizer import bfgs_utils
label_desc: Use image node_id 18 for calling the BfgsTest obj's underlying member method code with example usage: obj.test_dynamic_shapes() and returns: tf