class_docstr: A running R-hat diagnostic.
  
  `RunningPotentialScaleReduction` uses Gelman and Rubin (1992)'s potential
  scale reduction (also known as R-hat) for chain convergence [1].
  
  If multiple independent R-hat computations are desired across a latent
  state, one should use a (possibly nested) collection for initialization
  parameters `independent_chain_ndims` and `shape`. Subsequent chain states
  used to update the streaming R-hat should mimic their identical structure.
  
  `RunningPotentialScaleReduction` also assumes that incoming samples have shape
  `[Ci1, Ci2,...,CiD] + A`. Dimensions `0` through `D - 1` index the
  `Ci1 x ... x CiD` independent chains to be tested for convergence to the same
  target. The remaining dimensions, `A`, represent the event shape and hence,
  can have any shape (even empty, which implies scalar samples). The number of
  independent chain dimensions is defined by the `independent_chain_ndims`
  parameter at initialization.
  
  `RunningPotentialScaleReduction` is meant to serve general streaming R-hat.
  For a specialized version that fits streaming over MCMC samples, see
  `PotentialScaleReductionReducer` in `tfp.experimental.mcmc`.
  
  #### References
  
  [1]: Andrew Gelman and Donald B. Rubin. Inference from Iterative Simulation
       Using Multiple Sequences. _Statistical Science_, 7(4):457-472, 1992.
docstr: Construct a `RunningPotentialScaleReduction`.
  
  Args:
    chain_variances: A `RunningVariance` or nested structure of
      `RunningVariance`s, giving the variance estimates for the variables of
      interest.
    independent_chain_ndims: A Python `int` or structure of Python `ints`
      parallel to `chain_variances` giving the number of leading dimensions in
      `chain_variances` that index the independent chains over which the
      potential scale reduction factor should be computed.  Must be at least
      1.
docstr_tok: ["Construct","a","`","RunningPotentialScaleReduction","`",".","Args",":","chain_variances",":","A","`","RunningVariance","`","or","nested","structure","of","`","RunningVariance","`","s",",","giving","the","variance","estimates","for","the","variables","of","interest",".","independent_chain_ndims",":","A","Python","`","int","`","or","structure","of","Python","`","ints","`","parallel","to","`","chain_variances","`","giving","the","number","of","leading","dimensions","in","`","chain_variances","`","that","index","the","independent","chains","over","which","the","potential","scale","reduction","factor","should","be","computed",".","Must","be","at","least","1","."]
code: def __init__(self, chain_variances, independent_chain_ndims):
      """Construct a `RunningPotentialScaleReduction`.
  
      Args:
        chain_variances: A `RunningVariance` or nested structure of
          `RunningVariance`s, giving the variance estimates for the variables of
          interest.
        independent_chain_ndims: A Python `int` or structure of Python `ints`
          parallel to `chain_variances` giving the number of leading dimensions in
          `chain_variances` that index the independent chains over which the
          potential scale reduction factor should be computed.  Must be at least
          1.
      """
      self.chain_variances = chain_variances
      self.independent_chain_ndims = independent_chain_ndims
  
imports: import functools
  import math
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import nest_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.mcmc import diagnostic
  from tensorflow.python.util import nest
label_desc: Use image node_id 1 to create a new RunningPotentialScaleReduction object from inherited base classes: ACClass with example: obj = RunningPotentialScaleReduction(chain_variances, independent_chain_ndims)