class_docstr: `PoissonLogNormalQuadratureCompound` distribution.
  
  The `PoissonLogNormalQuadratureCompound` is an approximation to a
  Poisson-LogNormal [compound distribution](
  https://en.wikipedia.org/wiki/Compound_probability_distribution), i.e.,
  
  ```none
  p(k|loc, scale)
  = int_{R_+} dl LogNormal(l | loc, scale) Poisson(k | l)
  approx= sum{ prob[d] Poisson(k | lambda(grid[d])) : d=0, ..., deg-1 }
  ```
  
  By default, the `grid` is chosen as quantiles of the `LogNormal` distribution
  parameterized by `loc`, `scale` and the `prob` vector is
  `[1. / quadrature_size]*quadrature_size`.
  
  In the non-approximation case, a draw from the LogNormal prior represents the
  Poisson rate parameter. Unfortunately, the non-approximate distribution lacks
  an analytical probability density function (pdf). Therefore the
  `PoissonLogNormalQuadratureCompound` class implements an approximation based
  on [quadrature](https://en.wikipedia.org/wiki/Numerical_integration).
  
  Note: although the `PoissonLogNormalQuadratureCompound` is approximately the
  Poisson-LogNormal compound distribution, it is itself a valid distribution.
  Viz., it possesses a `sample`, `log_prob`, `mean`, `variance`, etc. which are
  all mutually consistent.
  
  #### Mathematical Details
  
  The `PoissonLogNormalQuadratureCompound` approximates a Poisson-LogNormal
  [compound distribution](
  https://en.wikipedia.org/wiki/Compound_probability_distribution). Using
  variable-substitution and [numerical quadrature](
  https://en.wikipedia.org/wiki/Numerical_integration) (default:
  based on `LogNormal` quantiles) we can redefine the distribution to be a
  parameter-less convex combination of `deg` different Poisson samples.
  
  That is, defined over positive integers, this distribution is parameterized
  by a (batch of) `loc` and `scale` scalars.
  
  The probability density function (pdf) is,
  
  ```none
  pdf(k | loc, scale, deg)
    = sum{ prob[d] Poisson(k | lambda=exp(grid[d]))
          : d=0, ..., deg-1 }
  ```
  
  #### Examples
  
  ```python
  tfd = tfp.distributions
  
  # Create two batches of PoissonLogNormalQuadratureCompounds, one with
  # prior `loc = 0.` and another with `loc = 1.` In both cases `scale = 1.`
  pln = tfd.PoissonLogNormalQuadratureCompound(
      loc=[0., -0.5],
      scale=1.,
      quadrature_size=10,
      validate_args=True)
docstr: Constructs the PoissonLogNormalQuadratureCompound`.
  
  Note: `probs` returned by (optional) `quadrature_fn` are presumed to be
  either a length-`quadrature_size` vector or a batch of vectors in 1-to-1
  correspondence with the returned `grid`. (I.e., broadcasting is only
  partially supported.)
  
  Args:
    loc: `float`-like (batch of) scalar `Tensor`; the location parameter of
      the LogNormal prior.
    scale: `float`-like (batch of) scalar `Tensor`; the scale parameter of
      the LogNormal prior.
    quadrature_size: Python `int` scalar representing the number of quadrature
      points.
    quadrature_fn: Python callable taking `loc`, `scale`,
      `quadrature_size`, `validate_args` and returning `tuple(grid, probs)`
      representing the LogNormal grid and corresponding normalized weight.
      Default value: `quadrature_scheme_lognormal_quantiles`.
    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.
  
  Raises:
    TypeError: if `quadrature_grid` and `quadrature_probs` have different base
      `dtype`.
docstr_tok: ["Constructs","the","PoissonLogNormalQuadratureCompound","`",".","Note",":","`","probs","`","returned","by","(","optional",")","`","quadrature_fn","`","are","presumed","to","be","either","a","length-","`","quadrature_size","`","vector","or","a","batch","of","vectors","in","1-to-1","correspondence","with","the","returned","`","grid","`",".","(","I.e.",",","broadcasting","is","only","partially","supported",".",")","Args",":","loc",":","`","float","`","-like","(","batch","of",")","scalar","`","Tensor","`",";","the","location","parameter","of","the","LogNormal","prior",".","scale",":","`","float","`","-like","(","batch","of",")","scalar","`","Tensor","`",";","the","scale","parameter","of","the","LogNormal","prior",".","quadrature_size",":","Python","`","int","`","scalar","representing","the","number","of","quadrature","points",".","quadrature_fn",":","Python","callable","taking","`","loc","`",",","`","scale","`",",","`","quadrature_size","`",",","`","validate_args","`","and","returning","`","tuple","(","grid",",","probs",")","`","representing","the","LogNormal","grid","and","corresponding","normalized","weight",".","Default","value",":","`","quadrature_scheme_lognormal_quantiles","`",".","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",".","Raises",":","TypeError",":","if","`","quadrature_grid","`","and","`","quadrature_probs","`","have","different","base","`","dtype","`","."]
code: def __init__(
      self,
      loc,
      scale,
      quadrature_size=8,
      quadrature_fn=quadrature_scheme_lognormal_quantiles,
      validate_args=False,
      allow_nan_stats=True,
      name="PoissonLogNormalQuadratureCompound",
  ):
      """Constructs the PoissonLogNormalQuadratureCompound`.
  
      Note: `probs` returned by (optional) `quadrature_fn` are presumed to be
      either a length-`quadrature_size` vector or a batch of vectors in 1-to-1
      correspondence with the returned `grid`. (I.e., broadcasting is only
      partially supported.)
  
      Args:
        loc: `float`-like (batch of) scalar `Tensor`; the location parameter of
          the LogNormal prior.
        scale: `float`-like (batch of) scalar `Tensor`; the scale parameter of
          the LogNormal prior.
        quadrature_size: Python `int` scalar representing the number of quadrature
          points.
        quadrature_fn: Python callable taking `loc`, `scale`,
          `quadrature_size`, `validate_args` and returning `tuple(grid, probs)`
          representing the LogNormal grid and corresponding normalized weight.
          Default value: `quadrature_scheme_lognormal_quantiles`.
        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.
  
      Raises:
        TypeError: if `quadrature_grid` and `quadrature_probs` have different base
          `dtype`.
      """
      parameters = dict(locals())
      with tf.name_scope(name) as name:
          dtype = dtype_util.common_dtype([loc, scale], tf.float32)
          self._loc = tensor_util.convert_nonref_to_tensor(
              loc, name="loc", dtype=dtype
          )
          self._scale = tensor_util.convert_nonref_to_tensor(
              scale, name="scale", dtype=dtype
          )
          self._quadrature_fn = quadrature_fn
          dtype_util.assert_same_float_dtype([self._loc, self._scale])
  
          self._quadrature_size = quadrature_size
  
          super(PoissonLogNormalQuadratureCompound, self).__init__(
              dtype=dtype,
              reparameterization_type=reparameterization.NOT_REPARAMETERIZED,
              validate_args=validate_args,
              allow_nan_stats=allow_nan_stats,
              parameters=parameters,
              name=name,
          )
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import exp
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import poisson
  from tensorflow_probability.python.distributions import transformed_distribution
  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 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
label_desc: Use image node_id 1 to create a new PoissonLogNormalQuadratureCompound object from inherited base classes: distribution with example: obj = PoissonLogNormalQuadratureCompound(loc, scale, quadrature_size, quadrature_fn, validate_args, allow_nan_stats, name)