code: def _expectation_gaussian_linear(
      p: Gaussian,
      kernel: kernels.Linear,
      _: None,
      __: None,
      ___: None,
      nghp: None = None,
  ) -> tf.Tensor:
      """
      Compute the expectation:
      <diag(K_{X, X})>_p(X)
          - K_{.,.} :: Linear kernel
  
      :return: N
      """
      # use only active dimensions
      Xmu, _ = kernel.slice(p.mu, None)
      Xcov = kernel.slice_cov(p.cov)
  
      return tf.reduce_sum(
          kernel.variance * (tf.linalg.diag_part(Xcov) + Xmu**2), 1
      )
  
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 1 for calling a global function with example usage: _expectation_gaussian_linear(p, kernel, _, __, ___, nghp) and returns: tf