code: def filter_models_by_unmitigiated_score(
      all_models,
      models_frames,
      unmitigated_score,
      performance_metric="balanced_error",
      fairness_metric="equalized_odds",
      threshold=0.01,
  ):
      """Filter out models whose performance score is above the desired
      threshold. Out of the remaining model, return the models with the best
      score on the fairness metric.
  
      Parameters
      ----------
      all_models: Dictionary (Epsilon, Index) mapping (epilson, index number) pairs to a Model object
      models_frames: A DataFrame representing each model's performance and fairness score.
      unmitigated_score: The performance score of the unmitigated model.
      performance_metric: The model performance metric to threshold on.
      fairness_metric: The fairness metric to optimize for
      threshold: The threshold padding added to the :code:`unmitigated_score`.
  
      """
      # Create threshold based on balanced_error of unmitigated model and filter
      models_filtered = models_frames.query(
          f"{performance_metric} <= {unmitigated_score + threshold}"
      )
      best_row = models_filtered.sort_values(by=[fairness_metric]).iloc[
          0
      ]
      # Choose the model with smallest equalized_odds difference
      epsilon, index = best_row[["epsilon", "index"]]
      return {
          "model": all_models[epsilon][index],
          "epsilon": epsilon,
          "index": index,
      }
  
imports: import numpy
  import pandas
  import matplotlib.pyplot
  import lightgbm
  from sklearn.metrics import balanced_accuracy_score, roc_auc_score
  from sklearn.metrics import confusion_matrix
  from sklearn.pipeline import Pipeline
  from sklearn.preprocessing import StandardScaler
  from fairlearn.metrics import MetricFrame
  from fairlearn.metrics import count, selection_rate, equalized_odds_difference, false_positive_rate, false_negative_rate
  from fairlearn.postprocessing import ThresholdOptimizer
  from fairlearn.reductions import ExponentiatedGradient
  from fairlearn.reductions import EqualizedOdds
  from sklearn.model_selection import train_test_split
  import warnings
label_desc: Use image node_id 13 for calling a global function with example usage: filter_models_by_unmitigiated_score(all_models, models_frames, unmitigated_score, performance_metric, fairness_metric, threshold) and returns: dict