docstr: Tests 1-factor model with state dependent vol.
docstr_tok: ["Tests","1-factor","model","with","state","dependent","vol","."]
code: def test_state_dependent_vol_1_factor(self, dtype):
      """Tests 1-factor model with state dependent vol."""
      num_samples = 100000
  
      def discount_fn(x):
          return 0.01 * tf.ones_like(
              x, dtype=dtype
          )  # pylint: disable=cell-var-from-loop
  
      volatility = tff.math.piecewise.PiecewiseConstantFunc(
          [], values=self.volatility_1_factor, dtype=dtype
      )
  
      def _vol_fn(t, r):
          return volatility([t]) * tf.math.abs(r) ** 0.5
  
      process = tff.models.hjm.QuasiGaussianHJM(
          dim=1,
          mean_reversion=self.mean_reversion_1_factor,
          volatility=_vol_fn,
          initial_discount_rate_fn=discount_fn,
          dtype=dtype,
      )
      times = np.array([0.1, 1.0, 2.0, 3.0])
      _, discount_paths, _, _ = process.sample_paths(
          times,
          num_samples=num_samples,
          time_step=0.1,
          random_type=tff.math.random.RandomType.STATELESS_ANTITHETIC,
          seed=[1, 2],
          skip=1000000,
      )
      self.assertEqual(discount_paths.dtype, dtype)
      discount_paths = self.evaluate(discount_paths)
      self.assertAllEqual(discount_paths.shape, [num_samples, 4])
      discount_mean = np.mean(discount_paths, axis=0)
      expected_mean = np.exp(-0.01 * times)
      self.assertAllClose(
          discount_mean, expected_mean, rtol=2e-4, atol=2e-4
      )
  
file_path: tf-quant-finance/tf_quant_finance/models/hjm/quasi_gaussian_hjm_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 7 for calling the HJMModelTest obj's underlying member method code with example usage: obj.test_state_dependent_vol_1_factor(dtype) and returns: unknown, unknown