class_docstr: Abstract base class for inference. All inference algorithms in
  Edward inherit from `Inference`, sharing common methods and
  properties via a class hierarchy.
  
  Specific algorithms typically inherit from other subclasses of
  `Inference` rather than `Inference` directly. For example, one
  might inherit from the abstract classes `MonteCarlo` or
  `VariationalInference`.
  
  To build an algorithm inheriting from `Inference`, one must at the
  minimum implement `initialize` and `update`: the former builds
  the computational graph for the algorithm; the latter runs the
  computational graph for the algorithm.
  
  To reset inference (e.g., internal variable counters incremented
  over training), fetch inference's reset ops from session with
  `sess.run(inference.reset)`.
  
  #### Examples
  
  ```python
  # Set up probability model.
  mu = Normal(loc=0.0, scale=1.0)
  x = Normal(loc=mu, scale=1.0, sample_shape=50)
  
  # Set up posterior approximation.
  qmu_loc = tf.Variable(tf.random_normal([]))
  qmu_scale = tf.nn.softplus(tf.Variable(tf.random_normal([])))
  qmu = Normal(loc=qmu_loc, scale=qmu_scale)
  
  inference = ed.Inference({mu: qmu}, data={x: tf.zeros(50)})
  ```
class_docstr_tok: ["Abstract","base","class","for","inference",".","All","inference","algorithms","in","Edward","inherit","from","`","Inference","`",",","sharing","common","methods","and","properties","via","a","class","hierarchy",".","Specific","algorithms","typically","inherit","from","other","subclasses","of","`","Inference","`","rather","than","`","Inference","`","directly",".","For","example",",","one","might","inherit","from","the","abstract","classes","`","MonteCarlo","`","or","`","VariationalInference","`",".","To","build","an","algorithm","inheriting","from","`","Inference","`",",","one","must","at","the","minimum","implement","`","initialize","`","and","`","update","`",":","the","former","builds","the","computational","graph","for","the","algorithm",";","the","latter","runs","the","computational","graph","for","the","algorithm",".","To","reset","inference","(","e.g.",",","internal","variable","counters","incremented","over","training",")",",","fetch","inference","'s","reset","ops","from","session","with","`","sess.run","(","inference.reset",")","`",".","#","#","#","#","Examples","``","`","python","#","Set","up","probability","model",".","mu","=","Normal","(","loc=0.0",",","scale=1.0",")","x","=","Normal","(","loc=mu",",","scale=1.0",",","sample_shape=50",")","#","Set","up","posterior","approximation",".","qmu_loc","=","tf.Variable","(","tf.random_normal","(","[","]",")",")","qmu_scale","=","tf.nn.softplus","(","tf.Variable","(","tf.random_normal","(","[","]",")",")",")","qmu","=","Normal","(","loc=qmu_loc",",","scale=qmu_scale",")","inference","=","ed.Inference","(","{","mu",":","qmu","}",",","data=","{","x",":","tf.zeros","(","50",")","}",")","``","`"]
docstr: Create an inference algorithm.
  
  Args:
    latent_vars: dict.
      Collection of latent variables (of type `RandomVariable` or
      `tf.Tensor`) to perform inference on. Each random variable is
      binded to another random variable; the latter will infer the
      former conditional on data.
    data: dict.
      Data dictionary which binds observed variables (of type
      `RandomVariable` or `tf.Tensor`) to their realizations (of
      type `tf.Tensor`). It can also bind placeholders (of type
      `tf.Tensor`) used in the model to their realizations; and
      prior latent variables (of type `RandomVariable`) to posterior
      latent variables (of type `RandomVariable`).
docstr_tok: ["Create","an","inference","algorithm",".","Args",":","latent_vars",":","dict",".","Collection","of","latent","variables","(","of","type","`","RandomVariable","`","or","`","tf.Tensor","`",")","to","perform","inference","on",".","Each","random","variable","is","binded","to","another","random","variable",";","the","latter","will","infer","the","former","conditional","on","data",".","data",":","dict",".","Data","dictionary","which","binds","observed","variables","(","of","type","`","RandomVariable","`","or","`","tf.Tensor","`",")","to","their","realizations","(","of","type","`","tf.Tensor","`",")",".","It","can","also","bind","placeholders","(","of","type","`","tf.Tensor","`",")","used","in","the","model","to","their","realizations",";","and","prior","latent","variables","(","of","type","`","RandomVariable","`",")","to","posterior","latent","variables","(","of","type","`","RandomVariable","`",")","."]
code: def __init__(self, latent_vars=None, data=None):
      """Create an inference algorithm.
  
      Args:
        latent_vars: dict.
          Collection of latent variables (of type `RandomVariable` or
          `tf.Tensor`) to perform inference on. Each random variable is
          binded to another random variable; the latter will infer the
          former conditional on data.
        data: dict.
          Data dictionary which binds observed variables (of type
          `RandomVariable` or `tf.Tensor`) to their realizations (of
          type `tf.Tensor`). It can also bind placeholders (of type
          `tf.Tensor`) used in the model to their realizations; and
          prior latent variables (of type `RandomVariable`) to posterior
          latent variables (of type `RandomVariable`).
      """
      sess = get_session()
      if latent_vars is None:
          latent_vars = {}
      if data is None:
          data = {}
  
      check_latent_vars(latent_vars)
      self.latent_vars = latent_vars
  
      check_data(data)
      self.data = {}
      for key, value in six.iteritems(data):
          if (
              isinstance(key, tf.Tensor)
              and "Placeholder" in key.op.type
          ):
              self.data[key] = value
          elif isinstance(key, (RandomVariable, tf.Tensor)):
              if isinstance(value, (RandomVariable, tf.Tensor)):
                  self.data[key] = value
              elif isinstance(
                  value, (float, list, int, np.ndarray, np.number, str)
              ):
                  # If value is a Python type, store it in the graph.
                  # Assign its placeholder with the key's data type.
                  with tf.variable_scope(None, default_name="data"):
                      ph = tf.placeholder(key.dtype, np.shape(value))
                      var = tf.Variable(
                          ph, trainable=False, collections=[]
                      )
                      sess.run(var.initializer, {ph: value})
                      self.data[key] = var
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import numpy
  import six
  import tensorflow
  import os
  from datetime import datetime
  from edward.models import RandomVariable
  from edward.util import check_data, check_latent_vars, get_session, get_variables, Progbar, transform
  from tensorflow.contrib.distributions import bijectors
label_desc: Use image node_id 1 to create a new Inference object from inherited base classes: object with example: obj = Inference(latent_vars, data)