code: def _get_valid_sqrt_matrix(rho):
      """Returns a matrix L such that rho = LL^T."""
      e, v = tf.linalg.eigh(rho)
  
      def _psd_true():
          return tf.linalg.cholesky(rho)
  
      def _psd_false():
          realv = tf.math.real(v)
          adjusted_e = tf.linalg.diag(tf.maximum(tf.math.real(e), 1e-5))
          return tf.matmul(realv, tf.math.sqrt(adjusted_e))
  
      return tf.cond(
          tf.math.reduce_any(tf.less(tf.math.real(e), 1e-5)),
          _psd_false,
          _psd_true,
      )
  
file_path: tf-quant-finance/tf_quant_finance/models/hjm/quasi_gaussian_hjm.py
imports: from typing import Callable, Union, Tuple
  import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance.math import gradient
  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 1 for calling a global function with example usage: _get_valid_sqrt_matrix(rho) and returns: tf, tf, tf