class_docstr: Beta-Binomial compound distribution.
  
  The Beta-Binomial distribution is parameterized by (a batch of) `total_count`
  parameters, the number of trials per draw from Binomial distributions where
  the probabilities of success per trial are drawn from underlying Beta
  distributions; the Beta distributions are parameterized by `concentration1`
  (aka 'alpha') and `concentration0` (aka 'beta').
  
  Mathematically, it is (equivalent to) a special case of the
  Dirichlet-Multinomial over two classes, although the computational
  representation is slightly different: while the Beta-Binomial is a
  distribution over the number of successes in `total_count` trials, the
  two-class Dirichlet-Multinomial is a distribution over the number of successes
  and failures.
  
  #### Mathematical Details
  
  The Beta-Binomial is a distribution over the number of successes in
  `total_count` independent Binomial trials, with each trial having the same
  probability of success, the underlying probability being unknown but drawn
  from a Beta distribution with known parameters.
  
  The probability mass function (pmf) is,
  
  ```none
  pmf(k; n, a, b) = Beta(k + a, n - k + b) / Z
  Z = (k! (n - k)! / n!) * Beta(a, b)
  ```
  
  where:
  * `concentration1 = a > 0`,
  * `concentration0 = b > 0`,
  * `total_count = n`, `n` a positive integer,
  * `n!` is `n` factorial,
  * `Beta(x, y) = Gamma(x) Gamma(y) / Gamma(x + y)` is the
    [beta function](https://en.wikipedia.org/wiki/Beta_function), and
  * `Gamma` is the [gamma function](
    https://en.wikipedia.org/wiki/Gamma_function).
  
  Dirichlet-Multinomial is a [compound distribution](
  https://en.wikipedia.org/wiki/Compound_probability_distribution), i.e., its
  samples are generated as follows.
  
    1. Choose success probabilities:
       `probs ~ Beta(concentration1, concentration0)`
    2. Draw integers representing the number of successes:
       `counts ~ Binomial(total_count, probs)`
  
  Distribution parameters are automatically broadcast in all functions; see
  examples for details.
  
  #### Examples
  
  Create a single distribution, corresponding to 5 coin flips.
  
  ```python
  dist = BetaBinomial(total_count=5., concentration1=.5, concentration0=.5)
  ```
  
  Creates 3 distributions with differing numbers of coin flips. The
  concentration parameters are broadcast.
  
  ```python
  dist = BetaBinomial(
     total_count=[5., 10., 20.], concentration1=.5, concentration0=.5)
  ```
  
  Creates 3 distribution, with differing numbers of coin flips and differing
  concentration parameters.
  
  ```python
  dist = BetaBinomial(
     total_count=[5., 10., 20.],
     concentration1=[.5, 2., 3.],
     concentration0=[4., 3., 2.])
  ```
  
  The distribution `log_prob` functions can be evaluated on counts.
  
  ```python
  # counts same shape as p.
  counts = [1., 2, 3]
  dist.log_prob(counts)  # Shape [3]
  
  # p will be broadcast to [[.2, .3, .8], [.2, .3, .8]] to match counts.
  counts = [[1., 2, 1], [2, 2, 4]]
  dist.log_prob(counts)  # Shape [2, 3]
  
  # p will be broadcast to shape [5, 7, 3] to match counts.
  counts = [[...]]  # Shape [5, 7, 3]
  dist.log_prob(counts)  # Shape [5, 7, 3]
  ```
class_docstr_tok: ["Beta-Binomial","compound","distribution",".","The","Beta-Binomial","distribution","is","parameterized","by","(","a","batch","of",")","`","total_count","`","parameters",",","the","number","of","trials","per","draw","from","Binomial","distributions","where","the","probabilities","of","success","per","trial","are","drawn","from","underlying","Beta","distributions",";","the","Beta","distributions","are","parameterized","by","`","concentration1","`","(","aka","'alpha","'",")","and","`","concentration0","`","(","aka","'beta","'",")",".","Mathematically",",","it","is","(","equivalent","to",")","a","special","case","of","the","Dirichlet-Multinomial","over","two","classes",",","although","the","computational","representation","is","slightly","different",":","while","the","Beta-Binomial","is","a","distribution","over","the","number","of","successes","in","`","total_count","`","trials",",","the","two-class","Dirichlet-Multinomial","is","a","distribution","over","the","number","of","successes","and","failures",".","#","#","#","#","Mathematical","Details","The","Beta-Binomial","is","a","distribution","over","the","number","of","successes","in","`","total_count","`","independent","Binomial","trials",",","with","each","trial","having","the","same","probability","of","success",",","the","underlying","probability","being","unknown","but","drawn","from","a","Beta","distribution","with","known","parameters",".","The","probability","mass","function","(","pmf",")","is",",","``","`","none","pmf","(","k",";","n",",","a",",","b",")","=","Beta","(","k","+","a",",","n","-","k","+","b",")","\/","Z","Z","=","(","k","!","(","n","-","k",")","!","\/","n","!",")","*","Beta","(","a",",","b",")","``","`","where",":","*","`","concentration1","=","a",">","0","`",",","*","`","concentration0","=","b",">","0","`",",","*","`","total_count","=","n","`",",","`","n","`","a","positive","integer",",","*","`","n","!","`","is","`","n","`","factorial",",","*","`","Beta","(","x",",","y",")","=","Gamma","(","x",")","Gamma","(","y",")","\/","Gamma","(","x","+","y",")","`","is","the","[","beta","function","]","(","https",":","\/\/en.wikipedia.org\/wiki\/Beta_function",")",",","and","*","`","Gamma","`","is","the","[","gamma","function","]","(","https",":","\/\/en.wikipedia.org\/wiki\/Gamma_function",")",".","Dirichlet-Multinomial","is","a","[","compound","distribution","]","(","https",":","\/\/en.wikipedia.org\/wiki\/Compound_probability_distribution",")",",","i.e.",",","its","samples","are","generated","as","follows",".","1",".","Choose","success","probabilities",":","`","probs","~","Beta","(","concentration1",",","concentration0",")","`","2",".","Draw","integers","representing","the","number","of","successes",":","`","counts","~","Binomial","(","total_count",",","probs",")","`","Distribution","parameters","are","automatically","broadcast","in","all","functions",";","see","examples","for","details",".","#","#","#","#","Examples","Create","a","single","distribution",",","corresponding","to","5","coin","flips",".","``","`","python","dist","=","BetaBinomial","(","total_count=5.",",","concentration1=.5",",","concentration0=.5",")","``","`","Creates","3","distributions","with","differing","numbers","of","coin","flips",".","The","concentration","parameters","are","broadcast",".","``","`","python","dist","=","BetaBinomial","(","total_count=","[","5.",",","10.",",","20",".","]",",","concentration1=.5",",","concentration0=.5",")","``","`","Creates","3","distribution",",","with","differing","numbers","of","coin","flips","and","differing","concentration","parameters",".","``","`","python","dist","=","BetaBinomial","(","total_count=","[","5.",",","10.",",","20",".","]",",","concentration1=","[",".5",",","2.",",","3",".","]",",","concentration0=","[","4.",",","3.",",","2",".","]",")","``","`","The","distribution","`","log_prob","`","functions","can","be","evaluated","on","counts",".","``","`","python","#","counts","same","shape","as","p.","counts","=","[","1.",",","2",",","3","]","dist.log_prob","(","counts",")","#","Shape","[","3","]","#","p","will","be","broadcast","to","[","[",".2",",",".3",",",".8","]",",","[",".2",",",".3",",",".8","]","]","to","match","counts",".","counts","=","[","[","1.",",","2",",","1","]",",","[","2",",","2",",","4","]","]","dist.log_prob","(","counts",")","#","Shape","[","2",",","3","]","#","p","will","be","broadcast","to","shape","[","5",",","7",",","3","]","to","match","counts",".","counts","=","[","[","...","]","]","#","Shape","[","5",",","7",",","3","]","dist.log_prob","(","counts",")","#","Shape","[","5",",","7",",","3","]","``","`"]
docstr: Initialize a batch of BetaBinomial distributions.
  
  Args:
    total_count: Non-negative integer-valued tensor, whose dtype is the same
      as `concentration1` and `concentration0`. The shape is broadcastable to
      `[N1,..., Nm]` with `m >= 0`. When `total_count` is broadcast with
      `concentration1` and `concentration0`, it defines the distribution as a
      batch of `N1 x ... x Nm` different Beta-Binomial distributions. Its
      components should be equal to integer values.
    concentration1: Positive floating-point `Tensor` indicating mean number of
      successes. Specifically, the expected number of successes is
      `total_count * concentration1 / (concentration1 + concentration0)`.
    concentration0: Positive floating-point `Tensor` indicating mean number of
      failures; see description of `concentration1` for details.
    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.
    name: Python `str` name prefixed to Ops created by this class.
docstr_tok: ["Initialize","a","batch","of","BetaBinomial","distributions",".","Args",":","total_count",":","Non-negative","integer-valued","tensor",",","whose","dtype","is","the","same","as","`","concentration1","`","and","`","concentration0","`",".","The","shape","is","broadcastable","to","`","[","N1",",","...",",","Nm","]","`","with","`","m",">","=","0","`",".","When","`","total_count","`","is","broadcast","with","`","concentration1","`","and","`","concentration0","`",",","it","defines","the","distribution","as","a","batch","of","`","N1","x","...","x","Nm","`","different","Beta-Binomial","distributions",".","Its","components","should","be","equal","to","integer","values",".","concentration1",":","Positive","floating-point","`","Tensor","`","indicating","mean","number","of","successes",".","Specifically",",","the","expected","number","of","successes","is","`","total_count","*","concentration1","\/","(","concentration1","+","concentration0",")","`",".","concentration0",":","Positive","floating-point","`","Tensor","`","indicating","mean","number","of","failures",";","see","description","of","`","concentration1","`","for","details",".","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",".","name",":","Python","`","str","`","name","prefixed","to","Ops","created","by","this","class","."]
code: def __init__(
      self,
      total_count,
      concentration1,
      concentration0,
      validate_args=False,
      allow_nan_stats=True,
      name="BetaBinomial",
  ):
      """Initialize a batch of BetaBinomial distributions.
  
      Args:
        total_count: Non-negative integer-valued tensor, whose dtype is the same
          as `concentration1` and `concentration0`. The shape is broadcastable to
          `[N1,..., Nm]` with `m >= 0`. When `total_count` is broadcast with
          `concentration1` and `concentration0`, it defines the distribution as a
          batch of `N1 x ... x Nm` different Beta-Binomial distributions. Its
          components should be equal to integer values.
        concentration1: Positive floating-point `Tensor` indicating mean number of
          successes. Specifically, the expected number of successes is
          `total_count * concentration1 / (concentration1 + concentration0)`.
        concentration0: Positive floating-point `Tensor` indicating mean number of
          failures; see description of `concentration1` for details.
        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.
        name: Python `str` name prefixed to Ops created by this class.
      """
      parameters = dict(locals())
      with tf.name_scope(name) as name:
          dtype = dtype_util.common_dtype(
              [total_count, concentration1, concentration0],
              dtype_hint=tf.float32,
          )
          self._total_count = tensor_util.convert_nonref_to_tensor(
              total_count, dtype=dtype, name="total_count"
          )
          self._concentration1 = tensor_util.convert_nonref_to_tensor(
              concentration1, dtype=dtype, name="concentration1"
          )
          self._concentration0 = tensor_util.convert_nonref_to_tensor(
              concentration0, dtype=dtype, name="concentration0"
          )
  
          super(BetaBinomial, self).__init__(
              dtype=dtype,
              validate_args=validate_args,
              allow_nan_stats=allow_nan_stats,
              reparameterization_type=reparameterization.NOT_REPARAMETERIZED,
              parameters=parameters,
              name=name,
          )
  
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import binomial
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import gamma
  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
label_desc: Use image node_id 1 to create a new BetaBinomial object from inherited base classes: distribution, distribution with example: obj = BetaBinomial(total_count, concentration1, concentration0, validate_args, allow_nan_stats, name)