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: Starts an empty `RunningPotentialScaleReduction` from metadata.
  
  Args:
    shape: Python `Tuple` or `TensorShape` representing the shape of incoming
      samples. Using a collection implies that future samples will mimic that
      exact structure. This is useful to supply if the
      `RunningPotentialScaleReduction` will be carried by a `tf.while_loop`,
      so that broadcasting does not change the shape across loop iterations.
    independent_chain_ndims: Integer or Integer type `Tensor` with value
      `>= 1` giving the number of leading dimensions holding independent
      chain results to be tested for convergence. Using a collection
      implies that future samples will mimic that exact structure.
    dtype: Dtype of incoming samples and the resulting statistics.
      By default, the dtype is `tf.float32`. Any integer dtypes will be
      cast to corresponding floats (i.e. `tf.int32` will be cast to
      `tf.float32`), as intermediate calculations should be performing
      floating-point division.
  
  Returns:
    state: `RunningPotentialScaleReduction` representing a stream
      of no inputs.
docstr_tok: ["Starts","an","empty","`","RunningPotentialScaleReduction","`","from","metadata",".","Args",":","shape",":","Python","`","Tuple","`","or","`","TensorShape","`","representing","the","shape","of","incoming","samples",".","Using","a","collection","implies","that","future","samples","will","mimic","that","exact","structure",".","This","is","useful","to","supply","if","the","`","RunningPotentialScaleReduction","`","will","be","carried","by","a","`","tf.while_loop","`",",","so","that","broadcasting","does","not","change","the","shape","across","loop","iterations",".","independent_chain_ndims",":","Integer","or","Integer","type","`","Tensor","`","with","value","`",">","=","1","`","giving","the","number","of","leading","dimensions","holding","independent","chain","results","to","be","tested","for","convergence",".","Using","a","collection","implies","that","future","samples","will","mimic","that","exact","structure",".","dtype",":","Dtype","of","incoming","samples","and","the","resulting","statistics",".","By","default",",","the","dtype","is","`","tf.float32","`",".","Any","integer","dtypes","will","be","cast","to","corresponding","floats","(","i.e",".","`","tf.int32","`","will","be","cast","to","`","tf.float32","`",")",",","as","intermediate","calculations","should","be","performing","floating-point","division",".","Returns",":","state",":","`","RunningPotentialScaleReduction","`","representing","a","stream","of","no","inputs","."]
code: def from_shape(
      cls, shape=(), independent_chain_ndims=1, dtype=tf.float32
  ):
      """Starts an empty `RunningPotentialScaleReduction` from metadata.
  
      Args:
        shape: Python `Tuple` or `TensorShape` representing the shape of incoming
          samples. Using a collection implies that future samples will mimic that
          exact structure. This is useful to supply if the
          `RunningPotentialScaleReduction` will be carried by a `tf.while_loop`,
          so that broadcasting does not change the shape across loop iterations.
        independent_chain_ndims: Integer or Integer type `Tensor` with value
          `>= 1` giving the number of leading dimensions holding independent
          chain results to be tested for convergence. Using a collection
          implies that future samples will mimic that exact structure.
        dtype: Dtype of incoming samples and the resulting statistics.
          By default, the dtype is `tf.float32`. Any integer dtypes will be
          cast to corresponding floats (i.e. `tf.int32` will be cast to
          `tf.float32`), as intermediate calculations should be performing
          floating-point division.
  
      Returns:
        state: `RunningPotentialScaleReduction` representing a stream
          of no inputs.
      """
      dtype = tf.nest.map_structure(_float_dtype_like, dtype)
  
      dtype = nest_util.broadcast_structure(
          independent_chain_ndims, dtype
      )
      chain_variances = nest.map_structure_up_to(
          independent_chain_ndims,
          RunningVariance.from_shape,
          shape,
          dtype,
          check_types=False,
      )
      return cls(chain_variances, 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 4 for calling the RunningPotentialScaleReduction obj's underlying member method code with example usage: obj.from_shape(cls, shape, independent_chain_ndims, dtype) and returns: cls