docstr: Tests model with generic parameters in 2 dimensions.
docstr_tok: ["Tests","model","with","generic","parameters","in","2","dimensions","."]
code: def test_mean_variance_correlation_generic_2d(self):
      """Tests model with generic parameters in 2 dimensions."""
      for dtype in [tf.float32, tf.float64]:
          mean_reversion = tff.math.piecewise.PiecewiseConstantFunc(
              2 * [[0.1, 2.0]],
              values=[
                  3 * [self.mean_reversion[0]],
                  3 * [self.mean_reversion[0]],
              ],
              dtype=dtype,
          )
          # Volatility with batch dimesnion
          volatility = tff.math.piecewise.PiecewiseConstantFunc(
              [[0.1, 0.2, 0.5], [0.1, 2.0, 3.0]],
              values=[
                  4 * [self.volatility[0]],
                  4 * [self.volatility[1]],
              ],
              dtype=dtype,
          )
  
          def corr_matrix(t):
              one = tf.ones_like(t)
              row1 = tf.stack([one, 0.5 * t], axis=-1)
              row2 = tf.reverse(row1, [0])
              corr_matrix = tf.stack([row1, row2], axis=-1)
              return corr_matrix
  
          process = tff.models.hull_white.VectorHullWhiteModel(
              dim=2,
              mean_reversion=mean_reversion,
              volatility=volatility,
              corr_matrix=corr_matrix,
              initial_discount_rate_fn=self.instant_forward_rate_2d_fn,
              dtype=dtype,
          )
          times = [0.1, 0.5]
          paths = process.sample_paths(
              times,
              num_samples=50000,
              random_type=tff.math.random.RandomType.SOBOL,
              skip=100000,
              time_step=0.01,
          )
          self.assertEqual(paths.dtype, dtype)
          self.assertAllEqual(paths.shape, [50000, 2, 2])
          paths = self.evaluate(paths)
          paths = paths[
              :, -1, :
          ]  # Extract paths values for the terminal time
          mean = np.mean(paths, axis=0)
          variance = np.var(paths, axis=0)
          self.assertAllClose(
              mean, self.true_mean(times[-1]), rtol=1e-3, atol=1e-3
          )
          self.assertAllClose(
              variance, self.true_var(times[-1]), rtol=1e-3, atol=1e-3
          )
  
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 HullWhiteTest obj's underlying member method code with example usage: obj.test_mean_variance_correlation_generic_2d() and returns: corr_matrix