code: def _expectation_gaussian_linear_inducingpoints__linear_inducingpoints(
      p: Union[Gaussian, DiagonalGaussian],
      kern1: kernels.Linear,
      feat1: InducingPoints,
      kern2: kernels.Linear,
      feat2: InducingPoints,
      nghp: None = None,
  ) -> tf.Tensor:
      """
      Compute the expectation:
      expectation[n] = <Ka_{Z1, x_n} Kb_{x_n, Z2}>_p(x_n)
          - Ka_{.,.}, Kb_{.,.} :: Linear kernels
      Ka and Kb as well as Z1 and Z2 can differ from each other, but this is supported
      only if the Gaussian p is Diagonal (p.cov NxD) and Ka, Kb have disjoint active_dims
      in which case the joint expectations simplify into a product of expectations
  
      :return: NxMxM
      """
      if kern1.on_separate_dims(kern2) and isinstance(
          p, DiagonalGaussian
      ):  # no joint expectations required
          eKxz1 = expectation(p, (kern1, feat1))
          eKxz2 = expectation(p, (kern2, feat2))
          return eKxz1[:, :, None] * eKxz2[:, None, :]
  
      if kern1 != kern2 or feat1 != feat2:
          raise NotImplementedError(
              "The expectation over two kernels has only an "
              "analytical implementation if both kernels are equal."
          )
  
      kernel = kern1
      inducing_variable = feat1
  
      # use only active dimensions
      Xcov = kernel.slice_cov(
          tf.linalg.diag(p.cov)
          if isinstance(p, DiagonalGaussian)
          else p.cov
      )
      Z, Xmu = kernel.slice(inducing_variable.Z, p.mu)
  
      N = tf.shape(Xmu)[0]
      var_Z = kernel.variance * Z
      tiled_Z = tf.tile(tf.expand_dims(var_Z, 0), (N, 1, 1))  # NxMxD
      XX = Xcov + tf.expand_dims(Xmu, 1) * tf.expand_dims(
          Xmu, 2
      )  # NxDxD
      return tf.linalg.matmul(
          tf.linalg.matmul(tiled_Z, XX), tiled_Z, transpose_b=True
      )
  
file_path: GPflow/gpflow/expectations/linears.py
imports: from typing import Type, Union
  import tensorflow
  from check_shapes import check_shapes
  from ..None import kernels
  from ..None import mean_functions
  from ..inducing_variables import InducingPoints
  from ..probability_distributions import DiagonalGaussian, Gaussian, MarkovGaussian
  from .None import dispatch
  from .expectations import expectation
label_desc: Use image node_id 5 for calling a global function with example usage: _expectation_gaussian_linear_inducingpoints__linear_inducingpoints(p, kern1, feat1, kern2, feat2, nghp) and returns: tf, unknown