code: def _get_error_fn(
      tmpl: str,
      use_probability: bool = False,
      positive_class: Optional[str] = None,
  ):
      """
      :param tmpl: The template kind, e.g. `regression/v1`.
      :return: The error function for the provided template.
      """
      if tmpl == "regression/v1":
          return lambda predictions, targets: predictions - targets
      if tmpl == "classification/v1":
          if use_probability:
              # It computes error rate for binary classification since
              # positive class only exists in binary classification.
              def error_rate(
                  true_label, predicted_positive_class_proba
              ):
                  if true_label == positive_class:
                      # if true_label == positive_class then the probability is
                      # predicted_positive_class_proba but the error rate is
                      # 1 - predicted_positive_class_proba
                      return 1 - predicted_positive_class_proba
                  else:
                      # if true_label != positive_class then the probability is
                      # 1 - predicted_positive_class_proba but the error rate is
                      # predicted_positive_class_proba
                      return predicted_positive_class_proba
  
              return lambda predictions, targets: [
                  error_rate(x, y)
                  for (x, y) in zip(targets, predictions)
              ]
          else:
              return lambda predictions, targets: predictions != targets
      raise MlflowException(
          f"No error function for template kind {tmpl}",
          error_code=INVALID_PARAMETER_VALUE,
      )
  
file_path: mlflow/mlflow/recipes/utils/metrics.py
imports: import importlib
  import logging
  import sys
  from typing import Any, Dict, List, Optional
  from mlflow.exceptions import BAD_REQUEST, MlflowException
  from mlflow.models import EvaluationMetric, make_metric
  from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
label_desc: Use image node_id 1 for calling a global function with example usage: _get_error_fn(tmpl, use_probability, positive_class) and returns: function, function, function, unknown, predicted_positive_class_proba