docstr: Test that under certain conditions HJM matches analytic HW results.
docstr_tok: ["Test","that","under","certain","conditions","HJM","matches","analytic","HW","results","."]
code: def test_correctness_2_factor_hull_white_consistency_with_corr(
      self, valuation_method, error_tol
  ):
      """Test that under certain conditions HJM matches analytic HW results."""
      dtype = tf.float64
      expiries = np.array([1.0])
      fixed_leg_payment_times = np.array([1.25, 1.5, 1.75, 2.0])
      fixed_leg_daycount_fractions = 0.25 * np.ones_like(
          fixed_leg_payment_times
      )
      fixed_leg_coupon = 0.011 * np.ones_like(fixed_leg_payment_times)
      zero_rate_fn = lambda x: 0.01 * tf.ones_like(x, dtype=dtype)
  
      mu = 0.03
      vol1 = 0.02
      vol2 = 0.01
      rho = -0.5
      eff_vol = np.sqrt(vol1**2 + vol2**2 + 2 * rho * vol1 * vol2)
  
      hjm_price = tff.models.hjm.swaption_price(
          expiries=expiries,
          fixed_leg_payment_times=fixed_leg_payment_times,
          fixed_leg_daycount_fractions=fixed_leg_daycount_fractions,
          fixed_leg_coupon=fixed_leg_coupon,
          reference_rate_fn=zero_rate_fn,
          notional=100.0,
          num_hjm_factors=2,
          mean_reversion=[mu, mu],
          volatility=[vol1, vol2],
          corr_matrix=[[1, rho], [rho, 1]],
          valuation_method=valuation_method,
          time_step_finite_difference=0.05,
          num_grid_points_finite_difference=251,
          num_samples=50_000,
          time_step=0.1,
          random_type=tff.math.random.RandomType.STATELESS_ANTITHETIC,
          seed=[1, 2],
          dtype=dtype,
      )
      hjm_price = self.evaluate(hjm_price)
  
      hw_price = tff.models.hull_white.swaption_price(
          expiries=expiries,
          floating_leg_start_times=[0],  # Unused
          floating_leg_end_times=[0],  # Unused
          floating_leg_daycount_fractions=[0],  # Unused
          fixed_leg_payment_times=fixed_leg_payment_times,
          fixed_leg_daycount_fractions=fixed_leg_daycount_fractions,
          fixed_leg_coupon=fixed_leg_coupon,
          reference_rate_fn=zero_rate_fn,
          notional=100.0,
          mean_reversion=[mu],
          volatility=[eff_vol],
          use_analytic_pricing=True,
          dtype=dtype,
      )
      hw_price = self.evaluate(hw_price)
  
      self.assertNear(hjm_price, hw_price, error_tol)
  
file_path: tf-quant-finance/tf_quant_finance/models/hjm/swaption_pricing_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 9 for calling the HJMSwaptionTest obj's underlying member method code with example usage: obj.test_correctness_2_factor_hull_white_consistency_with_corr(valuation_method, error_tol) without return types