class_docstr: Ensemble of correlated Hull-White Models.
  
  Represents the Ito process:
  
  ```None
    dr_i(t) = (theta_i(t) - a_i(t) * r_i(t)) dt + sigma_i(t) * dW_{r_i}(t),
    1 <= i <= n,
  ```
  where `W_{r_i}` are 1D Brownian motions with a correlation matrix `Rho(t)`.
  For each `i`, `r_i` is the Hull-White process.
  `theta_i`, `a_i`, `sigma_i`, `Rho` are positive functions of time.
  `a_i` correspond to the mean-reversion rate, `sigma_i` is the volatility of
  the process, `theta_i(t)` is the function that determines long run behaviour
  of the process `r(t) = (r_1(t), ..., r_n(t))`
  and is computed to match the initial (at t=0) discount curve:
  
  ```None
  \theta_i = df_i(t) / dt + a_i * f_i(t) + 0.5 * sigma_i**2 / a_i
             * (1 - exp(-2 * a_i *t)), 1 <= i <= n
  ```
  where `f_i(t)` is the instantaneous forward rate at time `0` for a maturity
  `t` and `df_i(t)/dt` is the gradient of `f_i` with respect to the maturity.
  See Section 3.3.1 of [1] for details.
  
  The price at time `t` of a zero-coupon bond maturing at `T` is given by
  (Ref. [2]):
  
  ```None
  P(t,T) = P(0,T) / P(0,t) *
           exp(-(r(t) - f(0,t)) * G(t,T) - 0.5 * y(t) * G(t,T)^2)
  
  y(t) = int_0^t [exp(-2 int_u^t (a(s) ds)) sigma(u)^2 du]
  
  G(t,T) = int_t^T [exp(-int_t^u a(s) ds) du]
  ```
  
  If mean-reversion, `a_i`, is constant and the volatility (`sigma_i`), and
  correlation (`Rho`) are piecewise constant functions, the process is sampled
  exactly. Otherwise, Euler sampling is used.
  
  For `n=1` this class represents Hull-White Model (see
  tff.models.hull_white.HullWhiteModel1F).
  
  #### Example. Two correlated Hull-White processes.
  
  ```python
  import numpy as np
  import tensorflow as tf
  import tf_quant_finance as tff
  
  dtype = tf.float64
  # Mean-reversion is constant for the two processes. `mean_reversion(t)`
  # has shape `[dim] + t.shape`.
  mean_reversion = [0.03, 0.02]
  # Volatility is a piecewise constant function with jumps at the same locations
  # for both Hull-White processes. `volatility(t)` has shape `[dim] + t.shape`.
  volatility = tff.math.piecewise.PiecewiseConstantFunc(
      jump_locations=[[0.1, 2.], [0.1, 2.]],
      values=[[0.01, 0.02, 0.01], [0.01, 0.015, 0.01]],
      dtype=dtype)
  # Correlation matrix is constant
  corr_matrix = [[1., 0.1], [0.1, 1.]]
  initial_discount_rate_fn = lambda *args: [0.01, 0.015]
  process = tff.models.hull_white.VectorHullWhiteModel(
      dim=2, mean_reversion=mean_reversion,
      volatility=volatility,
      initial_discount_rate_fn=initial_discount_rate_fn,
      corr_matrix=corr_matrix,
      dtype=dtype)
  # Sample 10000 paths using Sobol numbers as a random type.
  times = np.linspace(0., 1.0, 10)
  num_samples = 10000  # number of trajectories
  paths = process.sample_paths(
      times,
      num_samples=num_samples,
      random_type=tff.math.random.RandomType.SOBOL,
      seed=[4, 2])
  # Compute mean for each Hull-White process at the terminal value
  tf.math.reduce_mean(paths[:, -1, :], axis=0)
  # Expected: [0.01070005, 0.01540942]
  
  # User can supply time discretization grid along with the underlying
  # normal draws directly to the sampler.
  times_grid = tf.sort(tf.concat([np.linspace(0., 1.0, 10), [0.1]], axis=-1))
  normal_draws = tf.random.stateless_normal(
      [num_samples // 2, 10, 2], seed=[4, 2], dtype=dtype)
  normal_draws = tf.concat([normal_draws, -normal_draws], axis=0)
  paths = process.sample_paths(
      times,
      num_samples=num_samples,
      times_grid = times_grid,
      normal_draws=normal_draws)
  # Compute mean for each Hull-White process at the terminal value
  tf.math.reduce_mean(paths[:, -1, :], axis=0)
  # Expected: [0.0101668 , 0.01509873]
  ```
  
  #### References:
    [1]: D. Brigo, F. Mercurio. Interest Rate Models. 2007.
    [2]: Leif B. G. Andersen and Vladimir V. Piterbarg. Interest Rate Modeling.
    Volume II: Term Structure Models.
class_docstr_tok: ["Ensemble","of","correlated","Hull-White","Models",".","Represents","the","Ito","process",":","``","`","None","dr_i","(","t",")","=","(","theta_i","(","t",")","-","a_i","(","t",")","*","r_i","(","t",")",")","dt","+","sigma_i","(","t",")","*","dW_","{","r_i","}","(","t",")",",","1","<","=","i","<","=","n",",","``","`","where","`","W_","{","r_i","}","`","are","1D","Brownian","motions","with","a","correlation","matrix","`","Rho","(","t",")","`",".","For","each","`","i","`",",","`","r_i","`","is","the","Hull-White","process",".","`","theta_i","`",",","`","a_i","`",",","`","sigma_i","`",",","`","Rho","`","are","positive","functions","of","time",".","`","a_i","`","correspond","to","the","mean-reversion","rate",",","`","sigma_i","`","is","the","volatility","of","the","process",",","`","theta_i","(","t",")","`","is","the","function","that","determines","long","run","behaviour","of","the","process","`","r","(","t",")","=","(","r_1","(","t",")",",","...",",","r_n","(","t",")",")","`","and","is","computed","to","match","the","initial","(","at","t=0",")","discount","curve",":","``","`","None","\\theta_i","=","df_i","(","t",")","\/","dt","+","a_i","*","f_i","(","t",")","+","0.5","*","sigma_i","*","*","2","\/","a_i","*","(","1","-","exp","(","-2","*","a_i","*","t",")",")",",","1","<","=","i","<","=","n","``","`","where","`","f_i","(","t",")","`","is","the","instantaneous","forward","rate","at","time","`","0","`","for","a","maturity","`","t","`","and","`","df_i","(","t",")","\/dt","`","is","the","gradient","of","`","f_i","`","with","respect","to","the","maturity",".","See","Section","3.3.1","of","[","1","]","for","details",".","The","price","at","time","`","t","`","of","a","zero-coupon","bond","maturing","at","`","T","`","is","given","by","(","Ref",".","[","2","]",")",":","``","`","None","P","(","t",",","T",")","=","P","(","0",",","T",")","\/","P","(","0",",","t",")","*","exp","(","-","(","r","(","t",")","-","f","(","0",",","t",")",")","*","G","(","t",",","T",")","-","0.5","*","y","(","t",")","*","G","(","t",",","T",")","^2",")","y","(","t",")","=","int_0^t","[","exp","(","-2","int_u^t","(","a","(","s",")","ds",")",")","sigma","(","u",")","^2","du","]","G","(","t",",","T",")","=","int_t^T","[","exp","(","-int_t^u","a","(","s",")","ds",")","du","]","``","`","If","mean-reversion",",","`","a_i","`",",","is","constant","and","the","volatility","(","`","sigma_i","`",")",",","and","correlation","(","`","Rho","`",")","are","piecewise","constant","functions",",","the","process","is","sampled","exactly",".","Otherwise",",","Euler","sampling","is","used",".","For","`","n=1","`","this","class","represents","Hull-White","Model","(","see","tff.models.hull_white.HullWhiteModel1F",")",".","#","#","#","#","Example",".","Two","correlated","Hull-White","processes",".","``","`","python","import","numpy","as","np","import","tensorflow","as","tf","import","tf_quant_finance","as","tff","dtype","=","tf.float64","#","Mean-reversion","is","constant","for","the","two","processes",".","`","mean_reversion","(","t",")","`","#","has","shape","`","[","dim","]","+","t.shape","`",".","mean_reversion","=","[","0.03",",","0.02","]","#","Volatility","is","a","piecewise","constant","function","with","jumps","at","the","same","locations","#","for","both","Hull-White","processes",".","`","volatility","(","t",")","`","has","shape","`","[","dim","]","+","t.shape","`",".","volatility","=","tff.math.piecewise.PiecewiseConstantFunc","(","jump_locations=","[","[","0.1",",","2",".","]",",","[","0.1",",","2",".","]","]",",","values=","[","[","0.01",",","0.02",",","0.01","]",",","[","0.01",",","0.015",",","0.01","]","]",",","dtype=dtype",")","#","Correlation","matrix","is","constant","corr_matrix","=","[","[","1.",",","0.1","]",",","[","0.1",",","1",".","]","]","initial_discount_rate_fn","=","lambda","*","args",":","[","0.01",",","0.015","]","process","=","tff.models.hull_white.VectorHullWhiteModel","(","dim=2",",","mean_reversion=mean_reversion",",","volatility=volatility",",","initial_discount_rate_fn=initial_discount_rate_fn",",","corr_matrix=corr_matrix",",","dtype=dtype",")","#","Sample","10000","paths","using","Sobol","numbers","as","a","random","type",".","times","=","np.linspace","(","0.",",","1.0",",","10",")","num_samples","=","10000","#","number","of","trajectories","paths","=","process.sample_paths","(","times",",","num_samples=num_samples",",","random_type=tff.math.random.RandomType.SOBOL",",","seed=","[","4",",","2","]",")","#","Compute","mean","for","each","Hull-White","process","at","the","terminal","value","tf.math.reduce_mean","(","paths","[",":",",","-1",",",":","]",",","axis=0",")","#","Expected",":","[","0.01070005",",","0.01540942","]","#","User","can","supply","time","discretization","grid","along","with","the","underlying","#","normal","draws","directly","to","the","sampler",".","times_grid","=","tf.sort","(","tf.concat","(","[","np.linspace","(","0.",",","1.0",",","10",")",",","[","0.1","]","]",",","axis=-1",")",")","normal_draws","=","tf.random.stateless_normal","(","[","num_samples","\/\/","2",",","10",",","2","]",",","seed=","[","4",",","2","]",",","dtype=dtype",")","normal_draws","=","tf.concat","(","[","normal_draws",",","-normal_draws","]",",","axis=0",")","paths","=","process.sample_paths","(","times",",","num_samples=num_samples",",","times_grid","=","times_grid",",","normal_draws=normal_draws",")","#","Compute","mean","for","each","Hull-White","process","at","the","terminal","value","tf.math.reduce_mean","(","paths","[",":",",","-1",",",":","]",",","axis=0",")","#","Expected",":","[","0.0101668",",","0.01509873","]","``","`","#","#","#","#","References",":","[","1","]",":","D.","Brigo",",","F.","Mercurio",".","Interest","Rate","Models",".","2007",".","[","2","]",":","Leif","B.","G.","Andersen","and","Vladimir","V.","Piterbarg",".","Interest","Rate","Modeling",".","Volume","II",":","Term","Structure","Models","."]
docstr: Computes int_t0^t sigma(u)^2 exp(2*k*u) du.
docstr_tok: ["Computes","int_t0^t","sigma","(","u",")","^2","exp","(","2","*","k","*","u",")","du","."]
code: def _y_integral(self, t0, t, vol, k):
      """Computes int_t0^t sigma(u)^2 exp(2*k*u) du."""
      return (
          (vol * vol)
          / (2 * k)
          * (tf.math.exp(2 * k * t) - tf.math.exp(2 * k * t0))
      )
  
imports: from typing import Callable, Union, Tuple, Optional
  import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance import utils
  from tf_quant_finance.math import gradient
  from tf_quant_finance.math import piecewise
  from tf_quant_finance.math import random
  from tf_quant_finance.models import euler_sampling
  from tf_quant_finance.models import generic_ito_process
  from tf_quant_finance.models import utils
label_desc: Use image node_id 13 for calling the VectorHullWhiteModel obj's underlying member method code with example usage: obj._y_integral(t0, t, vol, k) and returns: unknown