from tensorflow.python.framework import constant_op


  @property
  def beta(self):
    """Scale parameter."""
    return self._beta

  def _batch_shape(self):
    return array_ops.broadcast_dynamic_shape(
        array_ops.shape(self.alpha), array_ops.shape(self.beta))

  def _get_batch_shape(self):
    return array_ops.broadcast_static_shape(
        self.alpha.get_shape(), self.beta.get_shape())

  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) -
