from tensorflow.python.ops import math_ops


  def _event_shape(self):
    return constant_op.constant([], dtype=dtypes.int32)

  def _get_event_shape(self):
    return tensor_shape.scalar()

  def _sample_n(self, n, seed=None):
    """See the documentation for tf.random_gamma for more details."""
    return 1. / random_ops.random_gamma([n], self.alpha, beta=self.beta,
                                        dtype=self.dtype, seed=seed)

  def _log_prob(self, x):
    x = control_flow_ops.with_dependencies([check_ops.assert_positive(x)] if
                                           self.validate_args else [], x)
    return (self.alpha * math_ops.log(self.beta) -
            math_ops.lgamma(self.alpha) -
            (self.alpha + 1.) * math_ops.log(x) - self.beta / x)

  def _prob(self, x):
    return math_ops.exp(self._log_prob(x))

  def _log_cdf(self, x):
    return math_ops.log(self._cdf(x))

  def _cdf(self, x):
    x = control_flow_ops.with_dependencies([check_ops.assert_positive(x)] if
                                           self.validate_args else [], x)
    # Note that igammac returns the upper regularized incomplete gamma
    # function Q(a, x), which is what we want for the CDF.
