class_docstr: Tests for methods in piecewise module.
class_docstr_tok: ["Tests","for","methods","in","piecewise","module","."]
docstr: Tests for dynamically shaped inputs.
docstr_tok: ["Tests","for","dynamically","shaped","inputs","."]
code: def test_dynamic_shapes(self):
      """Tests for dynamically shaped inputs."""
      dtype = np.float64
      x = tf.constant([[0, 1, 2, 3], [0.5, 1.5, 2.5, 3.5]], dtype=dtype)
      jump_locations = tf.constant([[0.5, 2], [0.5, 1.5]], dtype=dtype)
      values = tf.constant(
          [
              [[0, 1, 1.5], [2, 3, 0], [1, 0, 1]],
              [[0, 0.5, 1], [1, 3, 2], [2, 3, 1]],
          ],
          dtype=dtype,
      )
  
      @tf.function(
          input_signature=[
              tf.TensorSpec([None, None], dtype=dtype),
              tf.TensorSpec([None, None], dtype=dtype),
              tf.TensorSpec([None, None, None], dtype=dtype),
          ]
      )
      def fn(x, jump_locations, values):
          piecewise_func = piecewise.PiecewiseConstantFunc(
              jump_locations, values, dtype=dtype
          )
          value = piecewise_func(x)
          integral = piecewise_func.integrate(x, x + 1)
          return value, integral
  
      value, integral = fn(x, jump_locations, values)
      expected_value = [
          [[0, 1, 1.5], [2, 3, 0], [2, 3, 0], [1, 0, 1]],
          [[0, 0.5, 1], [1, 3, 2], [2, 3, 1], [2, 3, 1]],
      ]
      expected_integral = [
          [[1, 2, 0.75], [2, 3, 0], [1, 0, 1], [1, 0, 1]],
          [[1, 3, 2], [2, 3, 1], [2, 3, 1], [2, 3, 1]],
      ]
      with self.subTest("Values"):
          self.assertAllClose(
              value, expected_value, atol=1e-5, rtol=1e-5
          )
      with self.subTest("Integrals"):
          self.assertAllClose(
              integral, expected_integral, atol=1e-5, rtol=1e-5
          )
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 14 for calling the Piecewise obj's underlying member method code with example usage: obj.test_dynamic_shapes() and returns: value,  integral