class_docstr: `Reducer` that computes a running expectation.
  
  `ExpectationsReducer` calculates expectations over some arbitrary structure
  of `transform_fn`s. A `transform_fn` is a function that accepts a Markov
  chain sample and kernel results, and outputs the relevant value for
  expectation calculation. In other words, if we denote a `transform_fn`
  as f(x,y), `ExpectationsReducer` approximates E[f(x,y)] for all provided
  functions. The finalized expectation will also identically mimic the
  structure of `transform_fn`.
  
  As with all reducers, ExpectationsReducer does not hold state information;
  rather, it stores supplied metadata. Intermediate calculations are held in
  a state object, which is returned via `initialize` and `one_step` method
  calls.
class_docstr_tok: ["`","Reducer","`","that","computes","a","running","expectation",".","`","ExpectationsReducer","`","calculates","expectations","over","some","arbitrary","structure","of","`","transform_fn","`","s",".","A","`","transform_fn","`","is","a","function","that","accepts","a","Markov","chain","sample","and","kernel","results",",","and","outputs","the","relevant","value","for","expectation","calculation",".","In","other","words",",","if","we","denote","a","`","transform_fn","`","as","f","(","x",",","y",")",",","`","ExpectationsReducer","`","approximates","E","[","f","(","x",",","y",")","]","for","all","provided","functions",".","The","finalized","expectation","will","also","identically","mimic","the","structure","of","`","transform_fn","`",".","As","with","all","reducers",",","ExpectationsReducer","does","not","hold","state","information",";","rather",",","it","stores","supplied","metadata",".","Intermediate","calculations","are","held","in","a","state","object",",","which","is","returned","via","`","initialize","`","and","`","one_step","`","method","calls","."]
docstr: Instantiates this object.
  
  Args:
    transform_fn: A (possibly nested) structure of functions that accept a
      chain state and kernel results. Defaults to simply returning the
      incoming chain state.
    name: Python `str` name prefixed to Ops created by this function.
      Default value: `None` (i.e., 'expectations_reducer').
docstr_tok: ["Instantiates","this","object",".","Args",":","transform_fn",":","A","(","possibly","nested",")","structure","of","functions","that","accept","a","chain","state","and","kernel","results",".","Defaults","to","simply","returning","the","incoming","chain","state",".","name",":","Python","`","str","`","name","prefixed","to","Ops","created","by","this","function",".","Default","value",":","`","None","`","(","i.e.",",","'expectations_reducer","'",")","."]
code: def __init__(self, transform_fn=_get_sample, name=None):
      """Instantiates this object.
  
      Args:
        transform_fn: A (possibly nested) structure of functions that accept a
          chain state and kernel results. Defaults to simply returning the
          incoming chain state.
        name: Python `str` name prefixed to Ops created by this function.
          Default value: `None` (i.e., 'expectations_reducer').
      """
      self._parameters = dict(
          transform_fn=transform_fn, name=name or "expectations_reducer"
      )
  
file_path: probability/tensorflow_probability/python/experimental/mcmc/expectations_reducer.py
imports: import collections
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.mcmc import reducer
  from tensorflow_probability.python.experimental.stats import sample_stats
  from tensorflow_probability.python.internal import nest_util
  from tensorflow_probability.python.mcmc.internal import util
  from tensorflow.python.util import nest
label_desc: Use image node_id 1 to create a new ExpectationsReducer object from inherited base classes: reducer_base with example: obj = ExpectationsReducer(transform_fn, name)