code: def check_equality_predictions(
      data: RegressionData, models: Sequence[SVGP], decimal: int = 3
  ) -> None:
      """
      Executes a couple of checks to compare the equality of predictions
      of different models. The models should be configured with the same
      training data (X, Y). The following checks are done:
      - check if elbo is (almost) equal for all models
      - check if predicted mean is (almost) equal
      - check if predicted variance is (almost) equal.
        All possible variances over the inputs and outputs are calculated
        and equality is checked.
      - check if variances within model are consistent. Parts of the covariance
        matrices should overlap, and this is tested.
      """
  
      elbos = [m.elbo(data) for m in models]
  
      # Check equality of log likelihood
      assert_all_array_elements_almost_equal(elbos)
  
      # Predict: full_cov = True and full_output_cov = True
      means_tt, vars_tt = predict_all(
          models, Data.Xs, full_cov=True, full_output_cov=True
      )
      # Predict: full_cov = True and full_output_cov = False
      means_tf, vars_tf = predict_all(
          models, Data.Xs, full_cov=True, full_output_cov=False
      )
      # Predict: full_cov = False and full_output_cov = True
      means_ft, vars_ft = predict_all(
          models, Data.Xs, full_cov=False, full_output_cov=True
      )
      # Predict: full_cov = False and full_output_cov = False
      means_ff, vars_ff = predict_all(
          models, Data.Xs, full_cov=False, full_output_cov=False
      )
  
      # check equality of all the means
      all_means = means_tt + means_tf + means_ft + means_ff
      assert_all_array_elements_almost_equal(all_means)
  
      # check equality of all the variances within a category
      # (e.g. full_cov=True and full_output_cov=False)
      for var in [vars_tt, vars_tf, vars_ft, vars_ff]:
          assert_all_array_elements_almost_equal(var)
  
      # Here we check that the variance in different categories are equal
      # after transforming to the right shape.
      var_tt = vars_tt[0]  # N x P x N x P
      var_tf = vars_tf[0]  # P x N x c
      var_ft = vars_ft[0]  # N x P x P
      var_ff = vars_ff[0]  # N x P
  
      np.testing.assert_almost_equal(
          np.diagonal(var_tt, axis1=1, axis2=3),
          np.transpose(var_tf, [1, 2, 0]),
          decimal=decimal,
      )
      np.testing.assert_almost_equal(
          np.diagonal(var_tt, axis1=0, axis2=2),
          np.transpose(var_ft, [1, 2, 0]),
          decimal=decimal,
      )
      np.testing.assert_almost_equal(
          np.diagonal(np.diagonal(var_tt, axis1=0, axis2=2)),
          var_ff,
          decimal=decimal,
      )
  
imports: from typing import Callable, List, Sequence, Tuple, cast
  import numpy
  import pytest
  import scipy
  import tensorflow
  from _pytest.fixtures import SubRequest
  from check_shapes import ShapeChecker, check_shapes
  import gpflow
  import gpflow.inducing_variables.multioutput
  import gpflow.kernels.multioutput
  from gpflow import set_trainable
  from gpflow.base import AnyNDArray, RegressionData
  from gpflow.conditionals import sample_conditional
  from gpflow.conditionals.util import fully_correlated_conditional, fully_correlated_conditional_repeat, independent_interdomain_conditional, sample_mvn
  from gpflow.config import default_float, default_jitter
  from gpflow.inducing_variables import InducingPoints
  from gpflow.kernels import SquaredExponential
  from gpflow.likelihoods import Gaussian
  from gpflow.models import SVGP
label_desc: Use image node_id 3 for calling a global function with example usage: check_equality_predictions(data, models, decimal) without return types