code: def func_generator(metric, problem_type: str):
      """Create a custom metric compatible with XGBoost, based on the XGBoost 1.6+ API"""
      sign = -1 if metric.greater_is_better else 1
      needs_pred_proba = not metric.needs_pred
      if needs_pred_proba:
  
          def custom_metric(y_true, y_hat):
              return sign * metric(y_true, y_hat)
  
      else:
          if problem_type in [MULTICLASS, SOFTCLASS]:
  
              def custom_metric(y_true, y_hat):
                  y_hat = y_hat.argmax(axis=1)
                  return sign * metric(y_true, y_hat)
  
          elif problem_type == BINARY:
  
              def custom_metric(y_true, y_hat):
                  y_hat = np.round(y_hat)
                  return sign * metric(y_true, y_hat)
  
          else:
  
              def custom_metric(y_true, y_hat):
                  return sign * metric(y_true, y_hat)
  
      return custom_metric
  
file_path: autogluon/tabular/src/autogluon/tabular/models/xgboost/xgboost_utils.py
imports: from collections import OrderedDict
  import numpy
  from scipy.sparse import csr_matrix, hstack
  from sklearn.base import BaseEstimator, TransformerMixin
  from autogluon.core.constants import BINARY, MULTICLASS, REGRESSION, SOFTCLASS
  from ..tabular_nn.utils.categorical_encoders import OneHotMergeRaresHandleUnknownEncoder
label_desc: Use image node_id 2 for calling a global function with example usage: func_generator(metric, problem_type) and returns: custom_metric, unknown, unknown, unknown, unknown