code: def fully_correlated_conditional_repeat(
      Kmn: tf.Tensor,
      Kmm: tf.Tensor,
      Knn: tf.Tensor,
      f: tf.Tensor,
      *,
      full_cov: bool = False,
      full_output_cov: bool = False,
      q_sqrt: Optional[tf.Tensor] = None,
      white: bool = False,
  ) -> MeanAndVariance:
      """
      This function handles conditioning of multi-output GPs in the case where the conditioning
      points are all fully correlated, in both the prior and posterior.
      Note: This conditional can handle 'repetitions' R, given in `f` and `q_sqrt`.
  
      :param full_cov: calculate covariance between inputs
      :param full_output_cov: calculate covariance between outputs
      :param white: use whitened representation
      :return: mean, variance
      """
      R = tf.shape(f)[1]
      M, N, P = tf.unstack(tf.shape(Kmn), num=Kmn.shape.ndims, axis=0)
  
      Lm = tf.linalg.cholesky(Kmm)
  
      # Compute the projection matrix A
      # Lm: [M, M]    Kmn: [M, P]
      Kmn = tf.reshape(Kmn, (M, N * P))  # [M, P]
      A = tf.linalg.triangular_solve(Lm, Kmn, lower=True)  # [M, P]
      Ar = tf.reshape(A, (M, N, P))
  
      # compute the covariance due to the conditioning
      if full_cov and full_output_cov:
          # fvar = Knn - tf.linalg.matmul(Ar, Ar, transpose_a=True)  # [P, P], then reshape?
          fvar = Knn - tf.tensordot(Ar, Ar, [[0], [0]])  # [N, P, N, P]
      elif full_cov and not full_output_cov:
          At = tf.transpose(Ar)  # [P, N, M]
          fvar = Knn - tf.linalg.matmul(
              At, At, transpose_b=True
          )  # [P, N, N]
      elif not full_cov and full_output_cov:
          # This transpose is annoying
          At = tf.transpose(Ar, [1, 0, 2])  # [N, M, P]
          # fvar = Knn - tf.einsum('mnk,mnl->nkl', Ar, Ar)
          fvar = Knn - tf.linalg.matmul(
              At, At, transpose_a=True
          )  # [N, P, P]
      elif not full_cov and not full_output_cov:
          # Knn: [N, P]
          # Can also do this with a matmul
          fvar = Knn - tf.reshape(
              tf.reduce_sum(tf.square(A), [0]), (N, P)
          )
  
      # another backsubstitution in the unwhitened case
      if not white:
          A = tf.linalg.triangular_solve(Lm, A, adjoint=True)  # [M, P]
  
      # f: [M, R]
      fmean = tf.linalg.matmul(
          f, A, transpose_a=True
      )  # [R, M]  *  [M, P]  ->  [R, P]
      fmean = tf.reshape(fmean, (R, N, P))  # [R, N, P]
  
      if q_sqrt is not None:
          Lf = tf.linalg.band_part(q_sqrt, -1, 0)  # [R, M, M]
          if q_sqrt.shape.ndims == 3:
              A_tiled = tf.tile(
                  A[None, :, :], tf.stack([R, 1, 1])
              )  # [R, M, P]
              LTA = tf.linalg.matmul(
                  Lf, A_tiled, transpose_a=True
              )  # [R, M, P]
          elif q_sqrt.shape.ndims == 2:
              A_tiled = tf.tile(
                  A[None, :, :], tf.stack([R, 1, 1])
              )  # [R, M, P]
              LTA = Lf * A_tiled  # [R, M, P]
          else:  # pragma: no cover
              raise ValueError(
                  f"Bad dimension for q_sqrt: {q_sqrt.shape.ndims}"
              )
  
          if full_cov and full_output_cov:
              addvar = tf.linalg.matmul(
                  LTA, LTA, transpose_a=True
              )  # [R, P, P]
              fvar = fvar[None, :, :, :, :] + tf.reshape(
                  addvar, (R, N, P, N, P)
              )
          elif full_cov and not full_output_cov:
              LTAr = tf.transpose(
                  tf.reshape(LTA, [R, M, N, P]), [0, 3, 1, 2]
              )  # [R, P, M, N]
              addvar = tf.linalg.matmul(
                  LTAr, LTAr, transpose_a=True
              )  # [R, P, N, N]
              fvar = fvar[None, ...] + addvar  # [R, P, N, N]
          elif not full_cov and full_output_cov:
              LTAr = tf.transpose(
                  tf.reshape(LTA, (R, M, N, P)), [0, 2, 3, 1]
              )  # [R, N, P, M]
              fvar = fvar[None, ...] + tf.linalg.matmul(
                  LTAr, LTAr, transpose_b=True
              )  # [R, N, P, P]
          elif not full_cov and not full_output_cov:
              addvar = tf.reshape(
                  tf.reduce_sum(tf.square(LTA), axis=1), (R, N, P)
              )  # [R, N, P]
              fvar = fvar[None, ...] + addvar  # [R, N, P]
      else:
          fvar_shape = tf.concat([[R], tf.shape(fvar)], axis=0)
          fvar = tf.broadcast_to(fvar[None], fvar_shape)
  
      return fmean, fvar
  
file_path: GPflow/gpflow/conditionals/util.py
imports: from typing import Optional, Tuple
  import tensorflow
  from check_shapes import check_shape
  from check_shapes import check_shapes
  from ..base import MeanAndVariance
  from ..config import default_float, default_jitter
  from ..utilities.ops import leading_transpose
label_desc: Use image node_id 7 for calling a global function with example usage: fully_correlated_conditional_repeat(Kmn, Kmm, Knn, f) and returns: fmean,  fvar