code: def _create_sklearn_metric_flaml(
      metric_name: str, coeff: int, avg: str = "binary"
  ) -> callable:
      # pylint: disable=keyword-arg-before-vararg
      # pylint: disable=unused-argument
      def sklearn_metric(
          X_val,
          y_val,
          estimator,
          labels,
          X_train,
          y_train,
          weight_val=None,
          weight_train=None,
          *args,
      ):
          custom_metrics_mod = importlib.import_module(
              "sklearn.metrics"
          )
          eval_fn = getattr(custom_metrics_mod, metric_name)
          val_metric = coeff * eval_fn(
              y_val, estimator.predict(X_val), average=avg
          )
          train_metric = coeff * eval_fn(
              y_train, estimator.predict(X_train), average=avg
          )
          return val_metric, {
              f"{metric_name}_train": train_metric,
              f"{metric_name}_val": val_metric,
          }
  
      return sklearn_metric
  
file_path: mlflow/mlflow/recipes/steps/automl/flaml.py
imports: import importlib
  import logging
  from typing import TYPE_CHECKING, Any, Dict, Tuple
  import pandas
  import mlflow
  from mlflow import MlflowException
  from mlflow.models import EvaluationMetric
  from mlflow.models.evaluation.default_evaluator import _get_binary_classifier_metrics, _get_regressor_metrics
  from mlflow.recipes.utils.metrics import RecipeMetric, _load_custom_metrics
label_desc: Use image node_id 3 for calling a global function with example usage: _create_sklearn_metric_flaml(metric_name, coeff, avg) and returns: sklearn_metric, val_metric,  dict