class_docstr: `Reducer` that accumulates trace results at each sample.
  
  Trace results are defined by an appropriate `trace_fn`, which accepts the
  current chain state and kernel results, and returns the desired result.
  At each sample, the traced values are added to a `TensorArray` which
  accumulates all results. By default, all kernel results are traced but in the
  future the default will be changed to no results being traced, so plan
  accordingly.
  
  If wrapped in a `tfp.experimental.mcmc.WithReductions` Transition Kernel,
  TracingReducer will not accumulate the kernel results of `WithReductions`.
  Rather, the top level kernel results will be that of `WithReductions`' inner
  kernel.
  
  As with all reducers, `TracingReducer` does not hold state information;
  rather, it stores supplied metadata. Intermediate calculations are held in
  a `TracingState` named tuple, which is returned via `initialize` and
  `one_step` method calls.
class_docstr_tok: ["`","Reducer","`","that","accumulates","trace","results","at","each","sample",".","Trace","results","are","defined","by","an","appropriate","`","trace_fn","`",",","which","accepts","the","current","chain","state","and","kernel","results",",","and","returns","the","desired","result",".","At","each","sample",",","the","traced","values","are","added","to","a","`","TensorArray","`","which","accumulates","all","results",".","By","default",",","all","kernel","results","are","traced","but","in","the","future","the","default","will","be","changed","to","no","results","being","traced",",","so","plan","accordingly",".","If","wrapped","in","a","`","tfp.experimental.mcmc.WithReductions","`","Transition","Kernel",",","TracingReducer","will","not","accumulate","the","kernel","results","of","`","WithReductions","`",".","Rather",",","the","top","level","kernel","results","will","be","that","of","`","WithReductions","`","'","inner","kernel",".","As","with","all","reducers",",","`","TracingReducer","`","does","not","hold","state","information",";","rather",",","it","stores","supplied","metadata",".","Intermediate","calculations","are","held","in","a","`","TracingState","`","named","tuple",",","which","is","returned","via","`","initialize","`","and","`","one_step","`","method","calls","."]
docstr: Instantiates this object.
  
  TracingReducer can accumulate samples in a dynamic or static shape
  `TensorArray`. Specifying the `size` at instantiation will cause all
  subsequent state objects to hold a `TensorArray` of the same static size.
  If `size` is `None`, all `TensorArray`s will have dynamic size.
  
  Args:
    trace_fn: A callable that takes in the current chain state and the
      previous kernel results and return a `Tensor` or a nested collection
      of `Tensor`s that is accumulated across samples.
    size: Integer or scalar `Tensor` denoting the size of the accumulated
      `TensorArray`. If this is `None` (which is the default), a
      dynamic-shaped `TensorArray` will be used.
    name: Python `str` name prefixed to Ops created by this function.
      Default value: `None` (i.e., 'tracing_reducer').
docstr_tok: ["Instantiates","this","object",".","TracingReducer","can","accumulate","samples","in","a","dynamic","or","static","shape","`","TensorArray","`",".","Specifying","the","`","size","`","at","instantiation","will","cause","all","subsequent","state","objects","to","hold","a","`","TensorArray","`","of","the","same","static","size",".","If","`","size","`","is","`","None","`",",","all","`","TensorArray","`","s","will","have","dynamic","size",".","Args",":","trace_fn",":","A","callable","that","takes","in","the","current","chain","state","and","the","previous","kernel","results","and","return","a","`","Tensor","`","or","a","nested","collection","of","`","Tensor","`","s","that","is","accumulated","across","samples",".","size",":","Integer","or","scalar","`","Tensor","`","denoting","the","size","of","the","accumulated","`","TensorArray","`",".","If","this","is","`","None","`","(","which","is","the","default",")",",","a","dynamic-shaped","`","TensorArray","`","will","be","used",".","name",":","Python","`","str","`","name","prefixed","to","Ops","created","by","this","function",".","Default","value",":","`","None","`","(","i.e.",",","'tracing_reducer","'",")","."]
code: def __init__(
      self,
      trace_fn=_trace_state_and_kernel_results,
      size=None,
      name=None,
  ):
      """Instantiates this object.
  
      TracingReducer can accumulate samples in a dynamic or static shape
      `TensorArray`. Specifying the `size` at instantiation will cause all
      subsequent state objects to hold a `TensorArray` of the same static size.
      If `size` is `None`, all `TensorArray`s will have dynamic size.
  
      Args:
        trace_fn: A callable that takes in the current chain state and the
          previous kernel results and return a `Tensor` or a nested collection
          of `Tensor`s that is accumulated across samples.
        size: Integer or scalar `Tensor` denoting the size of the accumulated
          `TensorArray`. If this is `None` (which is the default), a
          dynamic-shaped `TensorArray` will be used.
        name: Python `str` name prefixed to Ops created by this function.
          Default value: `None` (i.e., 'tracing_reducer').
      """
      self._parameters = dict(
          trace_fn=trace_fn,
          size=size,
          name=name or "tracing_reducer",
      )
  
file_path: probability/tensorflow_probability/python/experimental/mcmc/tracing_reducer.py
imports: import collections
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.mcmc import reducer
  from tensorflow_probability.python.internal import loop_util
  from tensorflow_probability.python.mcmc.internal import util
label_desc: Use image node_id 1 to create a new TracingReducer object from inherited base classes: reducer_base with example: obj = TracingReducer(trace_fn, size, name)