code: def solve_det_conditional(x, sigma, A, Q):
      """
      Use matrix inversion lemma for the solve:
  
      .. math::
          (\\Sigma - AQ^{-1}A^T)^{-1} X =\\
          (\\Sigma^{-1} + \\Sigma^{-1} A (Q -
          A^T \\Sigma^{-1} A)^{-1} A^T \\Sigma^{-1}) X
  
      Use matrix determinant lemma for determinant:
  
      .. math::
          \\log|(\\Sigma - AQ^{-1}A^T)| =
          \\log|Q - A^T \\Sigma^{-1} A| - \\log|Q| + \\log|\\Sigma|
  
      Parameters
      ----------
      x: tf.Tensor
          Tensor to multiply the solve by
      sigma: brainiak.matnormal.CovBase
          Covariance object implementing solve and logdet
      A: tf.Tensor
          Factor multiplying the variable we conditioned on
      Q: brainiak.matnormal.CovBase
          Covariance object of conditioning variable,
          implementing solve and logdet
  
      """
  
      # (Q - A^T Sigma^{-1} A)
      lemma_factor = tlinalg.cholesky(
          Q._cov - tf.matmul(A, sigma.solve(A), transpose_a=True)
      )
  
      logdet = (
          -Q.logdet
          + sigma.logdet
          + 2
          * tf.reduce_sum(
              input_tensor=tf.math.log(tlinalg.diag_part(lemma_factor))
          )
      )
  
      # A^T Sigma^{-1}
      Atrp_Sinv = tf.matmul(A, sigma._prec, transpose_a=True)
      # (Q - A^T Sigma^{-1} A)^{-1} A^T Sigma^{-1}
      prod_term = tlinalg.cholesky_solve(lemma_factor, Atrp_Sinv)
  
      solve = tf.matmul(
          sigma.solve(
              scaled_I(1.0, sigma.size) + tf.matmul(A, prod_term)
          ),
          x,
      )
  
      return solve, logdet
  
file_path: brainiak/brainiak/matnormal/matnormal_likelihoods.py
imports: import tensorflow
  from tensorflow import linalg
  from .utils import scaled_I
  import logging
label_desc: Use image node_id 3 for calling a global function with example usage: solve_det_conditional(x, sigma, A, Q) and returns: solve,  logdet