docstr: Tests model with constant parameters in 1 dimension.
docstr_tok: ["Tests","model","with","constant","parameters","in","1","dimension","."]
code: def test_correctness_1d(self, time_step, num_time_steps, use_xla):
      """Tests model with constant parameters in 1 dimension."""
      dtype = tf.float64
      error_tol = 1e-2
  
      # 1y x 1y swaption with quarterly payments.
      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)
      mean_reversion = [0.03]
      volatility = [0.02]
  
      if use_xla:
          curve_times = np.array(fixed_leg_payment_times - expiries)
      else:
          curve_times = None
  
      def _fn():
          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=1,
              mean_reversion=mean_reversion,
              volatility=volatility,
              num_samples=50_000,
              time_step=time_step,
              num_time_steps=num_time_steps,
              curve_times=curve_times,
              random_type=tff.math.random.RandomType.STATELESS_ANTITHETIC,
              seed=[1, 2],
              dtype=dtype,
          )
          return price
  
      if use_xla:
          price = self.evaluate(tf.function(_fn, jit_compile=True)())
      else:
          price = self.evaluate(_fn())
      self.assertAllClose(
          price, [0.7163243383624043], rtol=error_tol, atol=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 1 for calling the HJMSwaptionTest obj's underlying member method code with example usage: obj.test_correctness_1d(time_step, num_time_steps, use_xla) and returns: price