code: def setUp(self):
      self.mean_reversion_1_factor = [0.03]
      self.volatility_1_factor = [0.01]
      self.mean_reversion_batch_1_factor = [[0.03], [0.04]]
      self.mean_reversion_batch_2_factor = [[0.03, 0.03], [0.04, 0.04]]
      self.volatility_batch_1_factor = [[0.01], [0.015]]
      self.volatility_batch_2_factor = [[0.005, 0.006], [0.004, 0.008]]
      self.mean_reversion_4_factor = [0.03, 0.02, 0.01, 0.005]
      self.volatility_4_factor = [0.01, 0.011, 0.015, 0.008]
      self.volatility_time_dep_1_factor = [0.01, 0.02, 0.01]
      self.instant_forward_rate = lambda *args: [0.01]
  
      def _instant_forward_rate_batch(t):
          ones = tf.transpose(tf.expand_dims(tf.ones_like(t), axis=0))
          return tf.transpose(
              tf.constant([0.01, 0.02], dtype=t.dtype) * ones
          )
  
      self.instant_forward_rate_batch = _instant_forward_rate_batch
  
      self.initial_state = [0.01, 0.01]
      self.initial_state_batch = [[[0.01]], [[0.02]]]
  
      # See D. Brigo, F. Mercurio. Interest Rate Models. 2007.
      def _true_mean(t, mr, vol, istate, f_0_t):
          dtype = np.float64
          a = dtype(mr)
          sigma = dtype(vol)
          initial_state = dtype(istate)
          return (
              dtype(f_0_t)
              + (sigma * sigma / 2 / a**2)
              * (1.0 - np.exp(-a * t)) ** 2
              - f_0_t * np.exp(-a * t)
              + initial_state * np.exp(-a * t)
          )
  
      self.true_mean = _true_mean
  
      def _true_var(t, mr, vol):
          dtype = np.float64
          a = dtype(mr)
          sigma = dtype(vol)
          return (sigma * sigma / 2 / a) * (1.0 - np.exp(-2 * a * t))
  
      self.true_var = _true_var
  
      def _true_std_time_dep(t, intervals, vol, k):
          res = np.zeros_like(t, dtype=np.float64)
          for i, tt in enumerate(t):
              var = 0.0
              for j in range(len(intervals) - 1):
                  if tt >= intervals[j] and tt < intervals[j + 1]:
                      var = var + vol[j] ** 2 / 2 / k * (
                          np.exp(2 * k * tt)
                          - np.exp(2 * k * intervals[j])
                      )
                      break
                  else:
                      var = var + vol[j] ** 2 / 2 / k * (
                          np.exp(2 * k * intervals[j + 1])
                          - np.exp(2 * k * intervals[j])
                      )
              else:
                  var = var + vol[-1] ** 2 / 2 / k * (
                      np.exp(2 * k * tt) - np.exp(2 * k * intervals[-1])
                  )
              res[i] = np.exp(-k * tt) * np.sqrt(var)
  
          return res
  
      self.true_std_time_dep = _true_std_time_dep
  
      def _true_zcb_std(t, tau, v, k):
          e_tau = np.exp(-k * tau)
          et = np.exp(k * t)
          val = (
              v
              / k
              * (1.0 - e_tau * et)
              * np.sqrt((1.0 - 1.0 / et / et) / k / 2)
          )
          return val
  
      self.true_zcb_std = _true_zcb_std
  
      super(HJMModelTest, self).setUp()
  
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 1 for calling the HJMModelTest obj's underlying member method code with example usage: obj.setUp() and returns: tf, unknown, unknown, res, val