code: def log_loss(
      labels, predictions, epsilon=1e-7, scope=None, weights=None
  ):
      """Calculate log losses.
  
      Same as tf.losses.log_loss except that this returns the individual losses
      instead of passing them into compute_weighted_loss and returning their
      weighted mean. This is useful for eval jobs that report the mean loss. By
      returning individual losses, that mean loss can be the same regardless of
      batch size.
  
      Args:
        labels: The ground truth output tensor, same dimensions as 'predictions'.
        predictions: The predicted outputs.
        epsilon: A small increment to add to avoid taking a log of zero.
        scope: The scope for the operations performed in computing the loss.
        weights: Weights to apply to labels.
  
      Returns:
        A `Tensor` representing the loss values.
  
      Raises:
        ValueError: If the shape of `predictions` doesn't match that of `labels`.
      """
      with tf.name_scope(scope, "log_loss", (predictions, labels)):
          predictions = tf.to_float(predictions)
          labels = tf.to_float(labels)
          predictions.get_shape().assert_is_compatible_with(
              labels.get_shape()
          )
          losses = -tf.multiply(
              labels, tf.log(predictions + epsilon)
          ) - tf.multiply(
              (1 - labels), tf.log(1 - predictions + epsilon)
          )
          if weights is not None:
              losses = tf.multiply(losses, weights)
  
          return losses
  
imports: from magenta.contrib import training
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling a global function with example usage: log_loss(labels, predictions, epsilon, scope, weights) and returns: losses