code: def log_loss(
      y_true,
      y_pred,
      *,
      eps=1e-15,
      normalize=True,
      sample_weight=None,
      labels=None,
  ):
      r"""Log loss, aka logistic loss or cross-entropy loss.
  
      This is the loss function used in (multinomial) logistic regression
      and extensions of it such as neural networks, defined as the negative
      log-likelihood of a logistic model that returns ``y_pred`` probabilities
      for its training data ``y_true``.
      The log loss is only defined for two or more labels.
      For a single sample with true label :math:`y \in \{0,1\}` and
      and a probability estimate :math:`p = \operatorname{Pr}(y = 1)`, the log
      loss is:
  
      .. math::
          L_{\log}(y, p) = -(y \log (p) + (1 - y) \log (1 - p))
  
      Read more in the :ref:`User Guide <log_loss>`.
  
      Parameters
      ----------
      y_true : array-like or label indicator matrix
          Ground truth (correct) labels for n_samples samples.
  
      y_pred : array-like of float, shape = (n_samples, n_classes) or (n_samples,)
          Predicted probabilities, as returned by a classifier's
          predict_proba method. If ``y_pred.shape = (n_samples,)``
          the probabilities provided are assumed to be that of the
          positive class. The labels in ``y_pred`` are assumed to be
          ordered alphabetically, as done by
          :class:`preprocessing.LabelBinarizer`.
  
      eps : float, default=1e-15
          Log loss is undefined for p=0 or p=1, so probabilities are
          clipped to max(eps, min(1 - eps, p)).
  
      normalize : bool, default=True
          If true, return the mean loss per sample.
          Otherwise, return the sum of the per-sample losses.
  
      sample_weight : array-like of shape (n_samples,), default=None
          Sample weights.
  
      labels : array-like, default=None
          If not provided, labels will be inferred from y_true. If ``labels``
          is ``None`` and ``y_pred`` has shape (n_samples,) the labels are
          assumed to be binary and are inferred from ``y_true``.
  
      Returns
      -------
      loss : float
  
      Notes
      -----
      The logarithm used is the natural logarithm (base-e).
  
      Examples
      --------
      >>> from mars.learn.metrics import log_loss
      >>> log_loss(["spam", "ham", "ham", "spam"],
      ...          [[.1, .9], [.9, .1], [.8, .2], [.35, .65]])
      0.21616...
  
      References
      ----------
      C.M. Bishop (2006). Pattern Recognition and Machine Learning. Springer,
      p. 209.
      """
      y_pred = check_array(y_pred, ensure_2d=False)
      check_consistent_length(y_pred, y_true, sample_weight)
  
      lb = LabelBinarizer()
  
      if labels is not None:
          lb.fit(labels)
      else:
          lb.fit(y_true)
  
      if len(lb.classes_) == 1:
          if labels is None:
              raise ValueError(
                  "y_true contains only one label ({0}). Please "
                  "provide the true labels explicitly through the "
                  "labels argument.".format(lb.classes_[0].fetch())
              )
          else:
              raise ValueError(
                  "The labels array needs to contain at least two "
                  "labels for log_loss, "
                  "got {0}.".format(lb.classes_.fetch())
              )
  
      transformed_labels = lb.transform(y_true)
  
      if transformed_labels.shape[1] == 1:
          transformed_labels = mt.append(
              1 - transformed_labels, transformed_labels, axis=1
          )
  
      # Clipping
      y_pred = mt.clip(y_pred, eps, 1 - eps)
  
      # If y_pred is of single dimension, assume y_true to be binary
      # and then check.
      if y_pred.ndim == 1:  # pragma: no cover
          y_pred = y_pred[:, mt.newaxis]
      if y_pred.shape[1] == 1:  # pragma: no cover
          y_pred = mt.append(1 - y_pred, y_pred, axis=1)
  
      # Check if dimensions are consistent.
      transformed_labels = check_array(transformed_labels)
      if len(lb.classes_) != y_pred.shape[1]:
          if labels is None:
              raise ValueError(
                  "y_true and y_pred contain different number of "
                  "classes {0}, {1}. Please provide the true "
                  "labels explicitly through the labels argument. "
                  "Classes found in "
                  "y_true: {2}".format(
                      transformed_labels.shape[1],
                      y_pred.shape[1],
                      lb.classes_.fetch(),
                  )
              )
          else:
              raise ValueError(
                  "The number of classes in labels is different "
                  "from that in y_pred. Classes found in "
                  "labels: {0}".format(lb.classes_.fetch())
              )
  
      # Renormalize
      y_pred /= y_pred.sum(axis=1)[:, mt.newaxis]
      loss = -(transformed_labels * mt.log(y_pred)).sum(axis=1)
  
      return _weighted_sum(loss, sample_weight, normalize).execute()
  
imports: import warnings
  import numpy
  from sklearn.exceptions import UndefinedMetricWarning
  from ...None import execute, fetch
  from ...None import opcodes
  from ...None import tensor
  from ...core import ENTITY_TYPE, recursive_tile
  from ...core.context import get_context
  from ...serialization.serializables import AnyField, BoolField, KeyField
  from ...tensor.core import TensorOrder
  from ..operands import LearnOperand, LearnOperandMixin, OutputType
  from ..preprocessing import LabelBinarizer, LabelEncoder
  from ..utils import check_array, check_consistent_length, column_or_1d
  from ..utils.multiclass import unique_labels
  from ..utils.sparsefuncs import count_nonzero
  from ._check_targets import _check_targets
label_desc: Use image node_id 3 for calling a global function with example usage: log_loss(y_true, y_pred) and returns: _weighted_sum