docstr: Tests with time dependent drift and variance.
docstr_tok: ["Tests","with","time","dependent","drift","and","variance","."]
code: def test_time_dependent_construction(self):
      """Tests with time dependent drift and variance."""
  
      def vol_fn(t):
          return tf.expand_dims(0.2 - 0.1 * tf.exp(-t), axis=-1)
  
      def variance_fn(t0, t1):
          # The instantaneous volatility is 0.2 - 0.1 e^(-t).
          tot_var = (t1 - t0) * 0.04 - (
              tf.exp(-2 * t1) - tf.exp(-2 * t0)
          ) * 0.005
          tot_var += 0.04 * (tf.exp(-t1) - tf.exp(-t0))
          return tf.reshape(tot_var, [-1, 1, 1])
  
      process = BrownianMotion(
          dim=1,
          drift=0.1,
          volatility=vol_fn,
          total_covariance_fn=variance_fn,
      )
      t0 = np.array([0.2, 0.7, 0.9])
      delta_t = np.array([0.1, 0.8, 0.3])
      t1 = t0 + delta_t
      drifts = self.evaluate(process.total_drift_fn()(t0, t1))
      self.assertArrayNear(drifts, 0.1 * delta_t, 1e-10)
      variances = self.evaluate(process.total_covariance_fn()(t0, t1))
      self.assertArrayNear(
          variances.reshape([-1]),
          [0.00149104, 0.02204584, 0.00815789],
          1e-8,
      )
  
file_path: tf-quant-finance/tf_quant_finance/models/legacy/brownian_motion_test.py
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow.python.framework import test_util
  from tf_quant_finance.models.legacy.brownian_motion import BrownianMotion
label_desc: Use image node_id 5 for calling the BrownianMotionTest obj's underlying member method code with example usage: obj.test_time_dependent_construction() and returns: tf, tf