'Build the graph for the NCE loss.'

def nce_loss(self, true_logits, sampled_logits):

    opts = self._options
    true_xent = tf.nn.sigmoid_cross_entropy_with_logits(labels=tf.ones_like(true_logits), logits=true_logits)
    sampled_xent = tf.nn.sigmoid_cross_entropy_with_logits(labels=tf.zeros_like(sampled_logits), logits=sampled_logits)
    nce_loss_tensor = ((tf.reduce_sum(true_xent) + tf.reduce_sum(sampled_xent)) / opts.batch_size)
    return nce_loss_tensor
