from tensorflow.python.ops import math_ops

  @distribution_util.AppendDocstring(
      """This is defined to be

      ```
      entropy = alpha - log(beta) + log(Gamma(alpha))
      + (1-alpha)digamma(alpha)
      ```

      where digamma(alpha) is the digamma function.""")
  def _entropy(self):
    return (self.alpha +
            math_ops.log(self.beta) +
            math_ops.lgamma(self.alpha) -
            (1. + self.alpha) * math_ops.digamma(self.alpha))

  @distribution_util.AppendDocstring(
      """The mean of an inverse gamma distribution is `beta / (alpha - 1)`,
      when `alpha > 1`, and `NaN` otherwise.  If `self.allow_nan_stats` is
      `False`, an exception will be raised rather than returning `NaN`""")
  def _mean(self):
    mean = self.beta / (self.alpha - 1.)
    if self.allow_nan_stats:
      nan = np.array(np.nan, dtype=self.dtype.as_numpy_dtype())
      return array_ops.where(
