code: def test_spots_and_discounts(self):
      dtype = np.float64
  
      observed_prices = np.array(
          [
              [
                  20.74264408,
                  13.0706132,
                  7.46141751,
                  3.8978837,
                  1.89302107,
              ],
              [
                  3.45098237,
                  6.92500205,
                  11.82124538,
                  17.9901047,
                  25.19373215,
              ],
          ],
          dtype=dtype,
      )
  
      strikes = np.array(
          [
              [80.0, 90.0, 100.0, 110.0, 120.0],
              [80.0, 90.0, 100.0, 110.0, 120.0],
          ],
          dtype=dtype,
      )
      expiries = np.array([[0.5], [1.0]], dtype=dtype)
      is_call_options = np.array([[True], [False]])
  
      discount_factors = np.array([[0.99], [0.98]], dtype=dtype)
      spots = np.array([[99.0], [98.0]], dtype=dtype)
  
      models, is_converged, _ = tff.models.heston.calibration(
          prices=observed_prices,
          strikes=strikes,
          expiries=expiries,
          spots=spots,
          discount_factors=discount_factors,
          is_call_options=is_call_options,
          mean_reversion=np.array([0.1], dtype=dtype),
          theta=np.array([0.3], dtype=dtype),
          initial_variance=np.array([0.01], dtype=dtype),
          volvol=np.array([0.2], dtype=dtype),
          rho=np.array([0.0], dtype=dtype),
          optimizer_fn=tff.math.optimizer.bfgs_minimize,
          maximum_iterations=100,
      )
  
      [
          calibrated_initial_variance,
          calibrated_mean_reversion,
          calibrated_volvol,
          calibrated_rho,
          calibrated_theta,
          is_converged,
      ] = self.evaluate(
          [
              models.initial_variance[:, tf.newaxis],
              models.mean_reversion[:, tf.newaxis],
              models.volvol[:, tf.newaxis],
              models.rho[:, tf.newaxis],
              models.theta[:, tf.newaxis],
              is_converged,
          ]
      )
  
      with self.subTest("AllConverged"):
          self.assertTrue(all(is_converged))
  
      calibrated_prices = (
          tff.models.heston.approximations.european_option_price(
              variances=calibrated_initial_variance,
              strikes=strikes,
              expiries=expiries,
              spots=spots,
              discount_factors=discount_factors,
              is_call_options=is_call_options,
              mean_reversion=calibrated_mean_reversion,
              theta=calibrated_theta,
              volvol=calibrated_volvol,
              rho=calibrated_rho,
              dtype=dtype,
          )
      )
      with self.subTest("PricesRecovered"):
          self.assertAllClose(
              calibrated_prices, observed_prices, atol=1e-3, rtol=1e-3
          )
  
file_path: tf-quant-finance/tf_quant_finance/models/heston/approximations/calibration_test.py
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 3 for calling the CalibrationTest obj's underlying member method code with example usage: obj.test_spots_and_discounts() without return types