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: Update the `RunningPotentialScaleReduction` with a new sample.
  
  Args:
    new_sample: Incoming `Tensor` sample or (possibly nested) collection of
      `Tensor`s with shape and dtype compatible with those used to form the
      `RunningPotentialScaleReduction`.
  
  Returns:
    state: `RunningPotentialScaleReduction` updated to include the new sample.
docstr_tok: ["Update","the","`","RunningPotentialScaleReduction","`","with","a","new","sample",".","Args",":","new_sample",":","Incoming","`","Tensor","`","sample","or","(","possibly","nested",")","collection","of","`","Tensor","`","s","with","shape","and","dtype","compatible","with","those","used","to","form","the","`","RunningPotentialScaleReduction","`",".","Returns",":","state",":","`","RunningPotentialScaleReduction","`","updated","to","include","the","new","sample","."]
code: def update(self, new_sample):
      """Update the `RunningPotentialScaleReduction` with a new sample.
  
      Args:
        new_sample: Incoming `Tensor` sample or (possibly nested) collection of
          `Tensor`s with shape and dtype compatible with those used to form the
          `RunningPotentialScaleReduction`.
  
      Returns:
        state: `RunningPotentialScaleReduction` updated to include the new sample.
      """
  
      def _update_for_one_state(chain_variances, new_sample):
          """Updates the running variance for one group of Markov chains."""
          # TODO(axch): chunking could be reasonably added here by accepting and
          # including the chunked axis to the running variance object
          return chain_variances.update(new_sample)
  
      updated_chain_variancess = tf.nest.map_structure(
          _update_for_one_state,
          self.chain_variances,
          new_sample,
          check_types=False,
      )
      return type(self)(
          updated_chain_variancess, self.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 6 for calling the RunningPotentialScaleReduction obj's underlying member method code with example usage: obj.update(new_sample) and returns: type, chain_variances