def _log_joint(self, z_sample):
    "Utility function to calculate model's log joint density,\n    log p(x, z), for inputs z (and fixed data x).\n\n    Args:\n      z_sample: dict.\n        Latent variable keys to samples.\n    "
    scope = tf.get_default_graph().unique_name('inference')
    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
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.
def _log_joint(self, z_sample):
    "Utility function to calculate model's log joint density,\n    log p(x, z), for inputs z (and fixed data x).\n\n    Args:\n      z_sample: dict.\n        Latent variable keys to samples.\n    "
    scope = tf.get_default_graph().unique_name('inference')
    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