class_docstr: Gamma distribution.
  
  The Gamma distribution is defined over positive real numbers using
  parameters `concentration` (aka "alpha") and `rate` (aka "beta").
  
  #### Mathematical Details
  
  The probability density function (pdf) is,
  
  ```none
  pdf(x; alpha, beta, x > 0) = x**(alpha - 1) exp(-x beta) / Z
  Z = Gamma(alpha) beta**(-alpha)
  ```
  
  where:
  
  * `concentration = alpha`, `alpha > 0`,
  * `rate = beta`, `beta > 0`,
  * `Z` is the normalizing constant, and,
  * `Gamma` is the [gamma function](
    https://en.wikipedia.org/wiki/Gamma_function).
  
  The cumulative density function (cdf) is,
  
  ```none
  cdf(x; alpha, beta, x > 0) = GammaInc(alpha, beta x) / Gamma(alpha)
  ```
  
  where `GammaInc` is the [lower incomplete Gamma function](
  https://en.wikipedia.org/wiki/Incomplete_gamma_function).
  
  The parameters can be intuited via their relationship to mean and stddev,
  
  ```none
  concentration = alpha = (mean / stddev)**2
  rate = beta = mean / stddev**2 = concentration / mean
  ```
  
  Distribution parameters are automatically broadcast in all functions; see
  examples for details.
  
  Warning: The samples of this distribution are always non-negative. However,
  the samples that are smaller than `np.finfo(dtype).tiny` are rounded
  to this value, so it appears more often than it should.
  This should only be noticeable when the `concentration` is very small, or the
  `rate` is very large. See note in `tf.random.gamma` docstring. To avoid this
  hazard, consider `tfp.distributions.ExpGamma`.
  
  Samples of this distribution are reparameterized (pathwise differentiable).
  The derivatives are computed using the approach described in the paper
  
  [Michael Figurnov, Shakir Mohamed, Andriy Mnih.
  Implicit Reparameterization Gradients, 2018](https://arxiv.org/abs/1805.08498)
  
  #### Examples
  
  ```python
  import tensorflow_probability as tfp
  tfd = tfp.distributions
  
  dist = tfd.Gamma(concentration=3.0, rate=2.0)
  dist2 = tfd.Gamma(concentration=[3.0, 4.0], rate=[2.0, 3.0])
  
  # Build a Gamma distribution equivalent to `dist`, parameterized by mean and
  # variance.
  dist_from_mean_var = tfd.Gamma.experimental_from_mean_variance(
    mean=1.5, variance=0.75)
  ```
  
  Compute the gradients of samples w.r.t. the parameters:
  
  ```python
  concentration = tf.constant(3.0)
  rate = tf.constant(2.0)
  dist = tfd.Gamma(concentration, rate)
  samples = dist.sample(5)  # Shape [5]
  loss = tf.reduce_mean(tf.square(samples))  # Arbitrary loss function
  # Unbiased stochastic gradients of the loss function
  grads = tf.gradients(loss, [concentration, rate])
  ```
class_docstr_tok: ["Gamma","distribution",".","The","Gamma","distribution","is","defined","over","positive","real","numbers","using","parameters","`","concentration","`","(","aka","``","alpha","''",")","and","`","rate","`","(","aka","``","beta","''",")",".","#","#","#","#","Mathematical","Details","The","probability","density","function","(","pdf",")","is",",","``","`","none","pdf","(","x",";","alpha",",","beta",",","x",">","0",")","=","x","*","*","(","alpha","-","1",")","exp","(","-x","beta",")","\/","Z","Z","=","Gamma","(","alpha",")","beta","*","*","(","-alpha",")","``","`","where",":","*","`","concentration","=","alpha","`",",","`","alpha",">","0","`",",","*","`","rate","=","beta","`",",","`","beta",">","0","`",",","*","`","Z","`","is","the","normalizing","constant",",","and",",","*","`","Gamma","`","is","the","[","gamma","function","]","(","https",":","\/\/en.wikipedia.org\/wiki\/Gamma_function",")",".","The","cumulative","density","function","(","cdf",")","is",",","``","`","none","cdf","(","x",";","alpha",",","beta",",","x",">","0",")","=","GammaInc","(","alpha",",","beta","x",")","\/","Gamma","(","alpha",")","``","`","where","`","GammaInc","`","is","the","[","lower","incomplete","Gamma","function","]","(","https",":","\/\/en.wikipedia.org\/wiki\/Incomplete_gamma_function",")",".","The","parameters","can","be","intuited","via","their","relationship","to","mean","and","stddev",",","``","`","none","concentration","=","alpha","=","(","mean","\/","stddev",")","*","*","2","rate","=","beta","=","mean","\/","stddev","*","*","2","=","concentration","\/","mean","``","`","Distribution","parameters","are","automatically","broadcast","in","all","functions",";","see","examples","for","details",".","Warning",":","The","samples","of","this","distribution","are","always","non-negative",".","However",",","the","samples","that","are","smaller","than","`","np.finfo","(","dtype",")",".tiny","`","are","rounded","to","this","value",",","so","it","appears","more","often","than","it","should",".","This","should","only","be","noticeable","when","the","`","concentration","`","is","very","small",",","or","the","`","rate","`","is","very","large",".","See","note","in","`","tf.random.gamma","`","docstring",".","To","avoid","this","hazard",",","consider","`","tfp.distributions.ExpGamma","`",".","Samples","of","this","distribution","are","reparameterized","(","pathwise","differentiable",")",".","The","derivatives","are","computed","using","the","approach","described","in","the","paper","[","Michael","Figurnov",",","Shakir","Mohamed",",","Andriy","Mnih",".","Implicit","Reparameterization","Gradients",",","2018","]","(","https",":","\/\/arxiv.org\/abs\/1805.08498",")","#","#","#","#","Examples","``","`","python","import","tensorflow_probability","as","tfp","tfd","=","tfp.distributions","dist","=","tfd.Gamma","(","concentration=3.0",",","rate=2.0",")","dist2","=","tfd.Gamma","(","concentration=","[","3.0",",","4.0","]",",","rate=","[","2.0",",","3.0","]",")","#","Build","a","Gamma","distribution","equivalent","to","`","dist","`",",","parameterized","by","mean","and","#","variance",".","dist_from_mean_var","=","tfd.Gamma.experimental_from_mean_variance","(","mean=1.5",",","variance=0.75",")","``","`","Compute","the","gradients","of","samples","w.r.t",".","the","parameters",":","``","`","python","concentration","=","tf.constant","(","3.0",")","rate","=","tf.constant","(","2.0",")","dist","=","tfd.Gamma","(","concentration",",","rate",")","samples","=","dist.sample","(","5",")","#","Shape","[","5","]","loss","=","tf.reduce_mean","(","tf.square","(","samples",")",")","#","Arbitrary","loss","function","#","Unbiased","stochastic","gradients","of","the","loss","function","grads","=","tf.gradients","(","loss",",","[","concentration",",","rate","]",")","``","`"]
docstr: Construct Gamma with `concentration` and `rate` parameters.
  
  The parameters `concentration` and `rate` must be shaped in a way that
  supports broadcasting (e.g. `concentration + rate` is a valid operation).
  
  Args:
    concentration: Floating point tensor, the concentration params of the
      distribution(s). Must contain only positive values.
    rate: Floating point tensor, the inverse scale params of the
      distribution(s). Must contain only positive values. Mutually exclusive
      with `log_rate`.
    log_rate: Floating point tensor, natural logarithm of the inverse scale
      params of the distribution(s). Mutually exclusive with `rate`.
    validate_args: Python `bool`, default `False`. When `True` distribution
      parameters are checked for validity despite possibly degrading runtime
      performance. When `False` invalid inputs may silently render incorrect
      outputs.
    allow_nan_stats: Python `bool`, default `True`. When `True`, statistics
      (e.g., mean, mode, variance) use the value "`NaN`" to indicate the
      result is undefined. When `False`, an exception is raised if one or
      more of the statistic's batch members are undefined.
    force_probs_to_zero_outside_support: If `True`, force `prob(x) == 0` and
      `log_prob(x) == -inf` for values of x outside the distribution support.
    name: Python `str` name prefixed to Ops created by this class.
  
  Raises:
    TypeError: if `concentration` and `rate` are different dtypes.
code: def __init__(
      self,
      concentration,
      rate=None,
      log_rate=None,
      validate_args=False,
      allow_nan_stats=True,
      force_probs_to_zero_outside_support=False,
      name="Gamma",
  ):
      """Construct Gamma with `concentration` and `rate` parameters.
  
      The parameters `concentration` and `rate` must be shaped in a way that
      supports broadcasting (e.g. `concentration + rate` is a valid operation).
  
      Args:
        concentration: Floating point tensor, the concentration params of the
          distribution(s). Must contain only positive values.
        rate: Floating point tensor, the inverse scale params of the
          distribution(s). Must contain only positive values. Mutually exclusive
          with `log_rate`.
        log_rate: Floating point tensor, natural logarithm of the inverse scale
          params of the distribution(s). Mutually exclusive with `rate`.
        validate_args: Python `bool`, default `False`. When `True` distribution
          parameters are checked for validity despite possibly degrading runtime
          performance. When `False` invalid inputs may silently render incorrect
          outputs.
        allow_nan_stats: Python `bool`, default `True`. When `True`, statistics
          (e.g., mean, mode, variance) use the value "`NaN`" to indicate the
          result is undefined. When `False`, an exception is raised if one or
          more of the statistic's batch members are undefined.
        force_probs_to_zero_outside_support: If `True`, force `prob(x) == 0` and
          `log_prob(x) == -inf` for values of x outside the distribution support.
        name: Python `str` name prefixed to Ops created by this class.
  
      Raises:
        TypeError: if `concentration` and `rate` are different dtypes.
      """
      parameters = dict(locals())
      self._force_probs_to_zero_outside_support = (
          force_probs_to_zero_outside_support
      )
      if (rate is None) == (log_rate is None):
          raise ValueError(
              "Exactly one of `rate` or `log_rate` must be specified."
          )
      with tf.name_scope(name) as name:
          dtype = dtype_util.common_dtype(
              [concentration, rate, log_rate], dtype_hint=tf.float32
          )
          self._concentration = tensor_util.convert_nonref_to_tensor(
              concentration, dtype=dtype, name="concentration"
          )
          self._rate = tensor_util.convert_nonref_to_tensor(
              rate, dtype=dtype, name="rate"
          )
          self._log_rate = tensor_util.convert_nonref_to_tensor(
              log_rate, dtype=dtype, name="log_rate"
          )
  
          super(Gamma, self).__init__(
              dtype=dtype,
              validate_args=validate_args,
              allow_nan_stats=allow_nan_stats,
              reparameterization_type=reparameterization.FULLY_REPARAMETERIZED,
              parameters=parameters,
              name=name,
          )
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import batched_rejection_sampler
  from tensorflow_probability.python.internal import custom_gradient
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import implementation_selection
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.math import generic
  from tensorflow_probability.python.math import special
  from tensorflow_probability.python.util.deferred_tensor import DeferredTensor
label_desc: Use image node_id 1 to create a new Gamma object from inherited base classes: distribution with example: obj = Gamma(concentration, rate, log_rate, validate_args, allow_nan_stats, force_probs_to_zero_outside_support, name)