docstr: Tests 1-factor model with time dependent vol.
docstr_tok: ["Tests","1-factor","model","with","time","dependent","vol","."]
code: def test_time_dependent_1d(self, dtype):
      """Tests 1-factor model with time 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(
          [0.1, 2.0],
          values=self.volatility_time_dep_1_factor,
          dtype=dtype,
      )
  
      def _vol_fn(t, r):
          del r
          return volatility([t])
  
      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])
      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(paths.dtype, dtype)
      paths = self.evaluate(paths)
      self.assertAllEqual(paths.shape, [num_samples, 4])
      r_std = np.squeeze(np.std(paths, axis=0))
      expected_std = self.true_std_time_dep(
          times,
          np.array([0.0, 0.1, 2.0]),
          np.array(self.volatility_time_dep_1_factor),
          self.mean_reversion_1_factor[0],
      )
      self.assertAllClose(
          r_std, expected_std, rtol=1.75e-4, atol=1.75e-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 6 for calling the HJMModelTest obj's underlying member method code with example usage: obj.test_time_dependent_1d(dtype) and returns: unknown, volatility