class_docstr: Beta distribution.
  
  The Beta distribution is defined over the `(0, 1)` interval using parameters
  `concentration1` (aka 'alpha') and `concentration0` (aka 'beta').
  
  #### Mathematical Details
  
  The probability density function (pdf) is,
  
  ```none
  pdf(x; alpha, beta) = x**(alpha - 1) (1 - x)**(beta - 1) / Z
  Z = Gamma(alpha) Gamma(beta) / Gamma(alpha + beta)
  ```
  
  where:
  
  * `concentration1 = alpha`,
  * `concentration0 = beta`,
  * `Z` is the normalization constant, and,
  * `Gamma` is the [gamma function](
    https://en.wikipedia.org/wiki/Gamma_function).
  
  The concentration parameters represent mean total counts of a `1` or a `0`,
  i.e.,
  
  ```none
  concentration1 = alpha = mean * total_concentration
  concentration0 = beta  = (1. - mean) * total_concentration
  ```
  
  where `mean` in `(0, 1)` and `total_concentration` is a positive real number
  representing a mean `total_count = concentration1 + concentration0`.
  
  Distribution parameters are automatically broadcast in all functions; see
  examples for details.
  
  Warning: The samples can be zero due to finite precision.
  This happens more often when some of the concentrations are very small.
  Make sure to round the samples to `np.finfo(dtype).tiny` before computing the
  density.
  
  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
  
  # Create a batch of three Beta distributions.
  alpha = [1, 2, 3]
  beta = [1, 2, 3]
  dist = tfd.Beta(alpha, beta)
  
  dist.sample([4, 5])  # Shape [4, 5, 3]
  
  # `x` has three batch entries, each with two samples.
  x = [[.1, .4, .5],
       [.2, .3, .5]]
  # Calculate the probability of each pair of samples under the corresponding
  # distribution in `dist`.
  dist.prob(x)         # Shape [2, 3]
  
  # Define an equivalent Beta distribution parameterized by `mean` and
  # `total_concentration`:
  dist = tfd.Beta.experimental_from_mean_concentration(
    mean=0.5, total_concentration=alpha+beta)
  ```
  
  ```python
  # Create batch_shape=[2, 3] via parameter broadcast:
  alpha = [[1.], [2]]      # Shape [2, 1]
  beta = [3., 4, 5]        # Shape [3]
  dist = tfd.Beta(alpha, beta)
  
  # alpha broadcast as: [[1., 1, 1,],
  #                      [2, 2, 2]]
  # beta broadcast as:  [[3., 4, 5],
  #                      [3, 4, 5]]
  # batch_Shape [2, 3]
  dist.sample([4, 5])  # Shape [4, 5, 2, 3]
  
  x = [.2, .3, .5]
  # x will be broadcast as [[.2, .3, .5],
  #                         [.2, .3, .5]],
  # thus matching batch_shape [2, 3].
  dist.prob(x)         # Shape [2, 3]
  ```
  
  Compute the gradients of samples w.r.t. the parameters:
  
  ```python
  alpha = tf.constant(1.0)
  beta = tf.constant(2.0)
  dist = tfd.Beta(alpha, beta)
  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, [alpha, beta])
  ```
class_docstr_tok: ["Beta","distribution",".","The","Beta","distribution","is","defined","over","the","`","(","0",",","1",")","`","interval","using","parameters","`","concentration1","`","(","aka","'alpha","'",")","and","`","concentration0","`","(","aka","'beta","'",")",".","#","#","#","#","Mathematical","Details","The","probability","density","function","(","pdf",")","is",",","``","`","none","pdf","(","x",";","alpha",",","beta",")","=","x","*","*","(","alpha","-","1",")","(","1","-","x",")","*","*","(","beta","-","1",")","\/","Z","Z","=","Gamma","(","alpha",")","Gamma","(","beta",")","\/","Gamma","(","alpha","+","beta",")","``","`","where",":","*","`","concentration1","=","alpha","`",",","*","`","concentration0","=","beta","`",",","*","`","Z","`","is","the","normalization","constant",",","and",",","*","`","Gamma","`","is","the","[","gamma","function","]","(","https",":","\/\/en.wikipedia.org\/wiki\/Gamma_function",")",".","The","concentration","parameters","represent","mean","total","counts","of","a","`","1","`","or","a","`","0","`",",","i.e.",",","``","`","none","concentration1","=","alpha","=","mean","*","total_concentration","concentration0","=","beta","=","(","1",".","-","mean",")","*","total_concentration","``","`","where","`","mean","`","in","`","(","0",",","1",")","`","and","`","total_concentration","`","is","a","positive","real","number","representing","a","mean","`","total_count","=","concentration1","+","concentration0","`",".","Distribution","parameters","are","automatically","broadcast","in","all","functions",";","see","examples","for","details",".","Warning",":","The","samples","can","be","zero","due","to","finite","precision",".","This","happens","more","often","when","some","of","the","concentrations","are","very","small",".","Make","sure","to","round","the","samples","to","`","np.finfo","(","dtype",")",".tiny","`","before","computing","the","density",".","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","#","Create","a","batch","of","three","Beta","distributions",".","alpha","=","[","1",",","2",",","3","]","beta","=","[","1",",","2",",","3","]","dist","=","tfd.Beta","(","alpha",",","beta",")","dist.sample","(","[","4",",","5","]",")","#","Shape","[","4",",","5",",","3","]","#","`","x","`","has","three","batch","entries",",","each","with","two","samples",".","x","=","[","[",".1",",",".4",",",".5","]",",","[",".2",",",".3",",",".5","]","]","#","Calculate","the","probability","of","each","pair","of","samples","under","the","corresponding","#","distribution","in","`","dist","`",".","dist.prob","(","x",")","#","Shape","[","2",",","3","]","#","Define","an","equivalent","Beta","distribution","parameterized","by","`","mean","`","and","#","`","total_concentration","`",":","dist","=","tfd.Beta.experimental_from_mean_concentration","(","mean=0.5",",","total_concentration=alpha+beta",")","``","`","``","`","python","#","Create","batch_shape=","[","2",",","3","]","via","parameter","broadcast",":","alpha","=","[","[","1",".","]",",","[","2","]","]","#","Shape","[","2",",","1","]","beta","=","[","3.",",","4",",","5","]","#","Shape","[","3","]","dist","=","tfd.Beta","(","alpha",",","beta",")","#","alpha","broadcast","as",":","[","[","1.",",","1",",","1",",","]",",","#","[","2",",","2",",","2","]","]","#","beta","broadcast","as",":","[","[","3.",",","4",",","5","]",",","#","[","3",",","4",",","5","]","]","#","batch_Shape","[","2",",","3","]","dist.sample","(","[","4",",","5","]",")","#","Shape","[","4",",","5",",","2",",","3","]","x","=","[",".2",",",".3",",",".5","]","#","x","will","be","broadcast","as","[","[",".2",",",".3",",",".5","]",",","#","[",".2",",",".3",",",".5","]","]",",","#","thus","matching","batch_shape","[","2",",","3","]",".","dist.prob","(","x",")","#","Shape","[","2",",","3","]","``","`","Compute","the","gradients","of","samples","w.r.t",".","the","parameters",":","``","`","python","alpha","=","tf.constant","(","1.0",")","beta","=","tf.constant","(","2.0",")","dist","=","tfd.Beta","(","alpha",",","beta",")","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",",","[","alpha",",","beta","]",")","``","`"]
code: def _log_prob(self, x):
      concentration0 = tf.convert_to_tensor(self.concentration0)
      concentration1 = tf.convert_to_tensor(self.concentration1)
      lp = self._log_unnormalized_prob(
          x, concentration1, concentration0
      ) - self._log_normalization(concentration1, concentration0)
      if self.force_probs_to_zero_outside_support:
          return tf.where((x >= 0) & (x <= 1), lp, -float("inf"))
      return lp
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import sigmoid
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import gamma
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  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.math import special
  from tensorflow_probability.python.util.deferred_tensor import DeferredTensor
label_desc: Use image node_id 11 for calling the Beta obj's underlying member method code with example usage: obj._log_prob(x) and returns: lp, tf