code: def unify_predict_fn(predict_fn, X, class_idx):
      if _pandas_installed and isinstance(X, pd.DataFrame):
          # scikit-learn now wants a Pandas dataframe if the model was trained on a Pandas dataframe,
          # so convert it
          names = X.columns
          if 0 <= class_idx:
              # classification
              def new_predict_fn(x):
                  # TODO: at some point we should also handle column position remapping when the column names match
                  X_fill = pd.DataFrame(x, columns=names)
                  return predict_fn(X_fill)[:, class_idx]
  
              return new_predict_fn
          else:
              # regression
              def new_predict_fn(x):
                  X_fill = pd.DataFrame(x, columns=names)
                  return predict_fn(X_fill)
  
              return new_predict_fn
      else:
          if 0 <= class_idx:
              # classification
              return lambda x: predict_fn(x)[:, class_idx]  # noqa: E731
          else:
              # regression
              return predict_fn
  
imports: import logging
  from sklearn.base import is_classifier, is_regressor
  from ._clean_simple import clean_dimensions
  from ._native import Native
label_desc: Use image node_id 2 for calling a global function with example usage: unify_predict_fn(predict_fn, X, class_idx) and returns: new_predict_fn, new_predict_fn, function, predict_fn, predict_fn, predict_fn