class_docstr: Use the transformed GP to give the *scale* (inverse rate) of the Gamma
class_docstr_tok: ["Use","the","transformed","GP","to","give","the","*","scale","*","(","inverse","rate",")","of","the","Gamma"]
code: def _variational_expectations(
      self,
      X: TensorType,
      Fmu: TensorType,
      Fvar: TensorType,
      Y: TensorType,
  ) -> tf.Tensor:
      if self.invlink is tf.exp:
          shape = self._shape(X)
          return tf.reduce_sum(
              -shape * Fmu
              - tf.math.lgamma(shape)
              + (shape - 1.0) * tf.math.log(Y)
              - Y * tf.exp(-Fmu + Fvar / 2.0),
              axis=-1,
          )
      else:
          return super()._variational_expectations(X, Fmu, Fvar, Y)
  
imports: from math import sqrt
  from typing import Any, Callable, Optional
  import numpy
  import tensorflow
  from check_shapes import check_shapes, inherit_check_shapes
  from ..None import logdensities
  from ..base import MeanAndVariance, TensorType
  from ..config import default_likelihood_positive_minimum
  from ..utilities.parameter_or_function import ConstantOrFunction, ParameterOrFunction, evaluate_parameter_or_function, prepare_parameter_or_function
  from .base import ScalarLikelihood
  from .utils import inv_probit
label_desc: Use image node_id 6 for calling the Gamma obj's underlying member method code with example usage: obj._variational_expectations(X, Fmu, Fvar, Y) and returns: tf, super