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: Number of trials.
docstr_tok: ["Number","of","trials","."]
code: def total_count(self):
      """Number of trials."""
      return self._total_count
  
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 3 for calling the BetaBinomial obj's underlying member method code with example usage: obj.total_count() and returns: self