code: def cross_entropy(input_,
                    labels,
                    name=PROVIDED,
                    loss_weight=None,
                    per_example_weights=None):
    
    if labels is None:
      raise ValueError('Labels must be set')
    labels = _convert_and_assert_tensors_compatible(input_, labels)
  
    if per_example_weights is not None:
      per_example_weights = _convert_and_assert_per_example_weights_compatible(
          input_,
          per_example_weights,
          dtype=input_.dtype)
  
    correct_predictions, examples = _compute_average_correct(
        input_, labels, per_example_weights)
    correct_ratio = correct_predictions / examples
    if correct_ratio.get_shape().is_fully_defined():
      input_.bookkeeper.add_average_summary(
          correct_ratio, 'average_accuracy_%s' % name)
    return apply_regression(
        input_,
        tf.contrib.nn.deprecated_flipped_softmax_cross_entropy_with_logits,
        labels,
        [],
        name='%s_loss' % name,
        loss_weight=loss_weight,
        per_example_weights=per_example_weights)
docs: Calculates the Cross Entropy of input_ vs labels.
  
    Args:
      input_: A rank 2 `Tensor` or a Pretty Tensor holding the logits.
      labels: A rank 2 tf.float32 or tf.float64 tensor containing the labels.
      name: The optional name.
      loss_weight: A weight to scale the loss. Used when there are multiple
        losses.
      per_example_weights: A weighting for each example.
    Returns:
      A loss.
    Raises:
      ValueError: if labels is None or the type is not float or double.