class_docstr: Stochastic gradient Langevin dynamics [@welling2011bayesian].
  
  #### Notes
  
  In conditional inference, we infer $z$ in $p(z, \beta
  \mid x)$ while fixing inference over $\beta$ using another
  distribution $q(\beta)$.
  `SGLD` substitutes the model's log marginal density
  
  $\log p(x, z) = \log \mathbb{E}_{q(\beta)} [ p(x, z, \beta) ]
                \approx \log p(x, z, \beta^*)$
  
  leveraging a single Monte Carlo sample, where $\beta^* \sim
  q(\beta)$. This is unbiased (and therefore asymptotically exact as a
  pseudo-marginal method) if $q(\beta) = p(\beta \mid x)$.
  
  #### Examples
  
  ```python
  mu = Normal(loc=0.0, scale=1.0)
  x = Normal(loc=mu, scale=1.0, sample_shape=10)
  
  qmu = Empirical(tf.Variable(tf.zeros(500)))
  inference = ed.SGLD({mu: qmu}, {x: np.zeros(10, dtype=np.float32)})
  ```
docstr: Utility function to calculate model's log joint density,
  log p(x, z), for inputs z (and fixed data x).
  
  Args:
    z_sample: dict.
      Latent variable keys to samples.
docstr_tok: ["Utility","function","to","calculate","model","'s","log","joint","density",",","log","p","(","x",",","z",")",",","for","inputs","z","(","and","fixed","data","x",")",".","Args",":","z_sample",":","dict",".","Latent","variable","keys","to","samples","."]
code: def _log_joint(self, z_sample):
      """Utility function to calculate model's log joint density,
      log p(x, z), for inputs z (and fixed data x).
  
      Args:
        z_sample: dict.
          Latent variable keys to samples.
      """
      scope = tf.get_default_graph().unique_name("inference")
      # Form dictionary in order to replace conditioning on prior or
      # observed variable with conditioning on a specific value.
      dict_swap = z_sample.copy()
      for x, qx in six.iteritems(self.data):
          if isinstance(x, RandomVariable):
              if isinstance(qx, RandomVariable):
                  qx_copy = copy(qx, scope=scope)
                  dict_swap[x] = qx_copy.value()
              else:
                  dict_swap[x] = qx
  
      log_joint = 0.0
      for z in six.iterkeys(self.latent_vars):
          z_copy = copy(z, dict_swap, scope=scope)
          log_joint += tf.reduce_sum(
              self.scale.get(z, 1.0) * z_copy.log_prob(dict_swap[z])
          )
  
      for x in six.iterkeys(self.data):
          if isinstance(x, RandomVariable):
              x_copy = copy(x, dict_swap, scope=scope)
              log_joint += tf.reduce_sum(
                  self.scale.get(x, 1.0) * x_copy.log_prob(dict_swap[x])
              )
  
      return log_joint
  
file_path: edward/edward/inferences/sgld.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import six
  import tensorflow
  from edward.inferences.monte_carlo import MonteCarlo
  from edward.models import RandomVariable
  from edward.util import copy
label_desc: Use image node_id 4 for calling the SGLD obj's underlying member method code with example usage: obj._log_joint(z_sample) and returns: log_joint