original_docstring: 
      objective function for fitting the latent variables for test points
      (negative log-likelihood: should be minimised!)
      
docstring: objective function for fitting the latent variables for test points
  (negative log-likelihood: should be minimised!)
docstring_tokens: objective function for fitting the latent variables for test points ( negative log - likelihood : should be minimised! )
code: def latent_cost_and_grad(mu_S, input_dim, kern, Z, dL_dpsi0, dL_dpsi1, dL_dpsi2):
      """
      objective function for fitting the latent variables for test points
      (negative log-likelihood: should be minimised!)
      """
      mu = mu_S[:input_dim][None]
      log_S = mu_S[input_dim:][None]
      S = np.exp(log_S)
  
      X = NormalPosterior(mu, S)
  
      psi0 = kern.psi0(Z, X)
      psi1 = kern.psi1(Z, X)
      psi2 = kern.psi2(Z, X)
  
      lik = dL_dpsi0 * psi0.sum() + np.einsum('ij,kj->...', dL_dpsi1, psi1) + np.einsum('ijk,lkj->...', dL_dpsi2, psi2) - 0.5 * np.sum(np.square(mu) + S) + 0.5 * np.sum(log_S)
  
      dLdmu, dLdS = kern.gradients_qX_expectations(dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, X)
      dmu = dLdmu - mu
      # dS = S0 + S1 + S2 -0.5 + .5/S
      dlnS = S * (dLdS - 0.5) + .5
  
      return -lik, -np.hstack((dmu.flatten(), dlnS.flatten()))
code_tokens: def latent_cost_and_grad ( mu_S , input_dim , kern , Z , dL_dpsi0 , dL_dpsi1 , dL_dpsi2 ) : mu = mu_S [ : input_dim ] [ None ] log_S = mu_S [ input_dim : ] [ None ] S = np . exp ( log_S ) X = NormalPosterior ( mu , S ) psi0 = kern . psi0 ( Z , X ) psi1 = kern . psi1 ( Z , X ) psi2 = kern . psi2 ( Z , X ) lik = dL_dpsi0 * psi0 . sum ( ) + np . einsum ( 'ij,kj->...' , dL_dpsi1 , psi1 ) + np . einsum ( 'ijk,lkj->...' , dL_dpsi2 , psi2 ) - 0.5 * np . sum ( np . square ( mu ) + S ) + 0.5 * np . sum ( log_S ) dLdmu , dLdS = kern . gradients_qX_expectations ( dL_dpsi0 , dL_dpsi1 , dL_dpsi2 , Z , X ) dmu = dLdmu - mu dlnS = S * ( dLdS - 0.5 ) + .5 return - lik , - np . hstack ( ( dmu . flatten ( ) , dlnS . flatten ( ) ) )
short_docstring: objective function for fitting the latent variables for test points
  (negative log-likelihood: should be minimised!)
short_docstring_tokens: objective function for fitting the latent variables for test points ( negative log - likelihood : should be minimised! )
comment: """
      objective function for fitting the latent variables for test points
      (negative log-likelihood: should be minimised!)
      """$SEP$# dS = S0 + S1 + S2 -0.5 + .5/S