code: def run_comparisons(moment, metric_fn):
      X, y = loan_scenario_generator(n, f, sfs, ibs, seed=163)
      X_dummy = pd.get_dummies(X)
  
      mf_input = MetricFrame(
          metrics=metric_fn,
          y_true=y,
          y_pred=y,
          sensitive_features=X["sens"],
          control_features=X["ctrl"],
      )
  
      print("Metric for input:\n", mf_input.by_group)
      print(
          "Input Metric differences:\n",
          mf_input.difference(method="to_overall"),
          "\n",
      )
  
      unmitigated = LogisticRegression()
      unmitigated.fit(X_dummy, y)
      y_pred = unmitigated.predict(X_dummy)
      mf_unmitigated = MetricFrame(
          metrics=metric_fn,
          y_true=y,
          y_pred=y_pred,
          sensitive_features=X["sens"],
          control_features=X["ctrl"],
      )
      print("Unmitigated metric:\n", mf_unmitigated.by_group)
      print(
          "Unmitigated metric differences:\n",
          mf_unmitigated.difference(method="to_overall"),
          "\n",
      )
  
      expgrad_basic = ExponentiatedGradient(
          LogisticRegression(), constraints=moment(), eps=0.005
      )
      expgrad_basic.fit(X_dummy, y, sensitive_features=X["sens"])
      y_pred_basic = expgrad_basic.predict(X_dummy, random_state=8235)
      mf_basic = MetricFrame(
          metrics=metric_fn,
          y_true=y,
          y_pred=y_pred_basic,
          sensitive_features=X["sens"],
          control_features=X["ctrl"],
      )
      print("Basic expgrad metric:\n", mf_basic.by_group)
      print(
          "Basic expgrad metric differences:\n",
          mf_basic.difference(method="to_overall"),
          "\n",
      )
  
      expgrad_control = ExponentiatedGradient(
          LogisticRegression(), constraints=moment(), eps=0.005
      )
      expgrad_control.fit(
          X_dummy,
          y,
          sensitive_features=X["sens"],
          control_features=X["ctrl"],
      )
      y_pred_control = expgrad_control.predict(
          X_dummy, random_state=852
      )
      mf_control = MetricFrame(
          metrics=metric_fn,
          y_true=y,
          y_pred=y_pred_control,
          sensitive_features=X["sens"],
          control_features=X["ctrl"],
      )
      print("expgrad_control metric:\n", mf_control.by_group)
      print(
          "expgrad_control metric differences:\n",
          mf_control.difference(method="to_overall"),
      )
  
      assert (
          mf_control.difference(method="to_overall")
          <= mf_unmitigated.difference(method="to_overall")
      ).all()
  
      assert (
          mf_control.difference(method="to_overall")
          <= mf_basic.difference(method="to_overall")
      ).all()
  
file_path: fairlearn/test/unit/reductions/exponentiated_gradient/test_control_features.py
imports: from test.unit.reductions.data_generators import loan_scenario_generator
  import pandas
  from sklearn.linear_model import LogisticRegression
  from sklearn.metrics import accuracy_score
  from fairlearn.metrics import MetricFrame, false_positive_rate, selection_rate, true_positive_rate
  from fairlearn.reductions import DemographicParity, EqualizedOdds, ErrorRateParity, ExponentiatedGradient, FalsePositiveRateParity, TruePositiveRateParity
label_desc: Use image node_id 1 for calling a global function with example usage: run_comparisons(moment, metric_fn) without return types