code: def _selected_label_compare(moment, metric, selected_label):
      # Similar to _simple_compare, but we need to worry about the y label
      X, y = loan_scenario_generator(n, f, sfs, ibs, seed=7132752)
      X_dummy = pd.get_dummies(X)
  
      est = LogisticRegression()
      est.fit(X_dummy, y)
      y_pred = est.predict(X_dummy)
  
      target = moment()
      target.load_data(
          X_dummy,
          y,
          sensitive_features=X["sens"],
          control_features=X["ctrl"],
      )
  
      # gamma measures the constraint violation relative to the overall value
      results = target.gamma(est.predict)
  
      # Compute the constraint violation using the metrics
      mf_pred = MetricFrame(
          metrics=metric,
          y_true=y,
          y_pred=y_pred,
          sensitive_features=X["sens"],
          control_features=X["ctrl"],
      )
      diffs = mf_pred.by_group - mf_pred.overall
  
      # Compare (with a very small amount of wriggle room)
      for ib in ibs:
          for sf in sfs:
              # Format defined within utility_parity._combine_event_and_control
              label_format = "control={0},label={1}"
              label = label_format.format(ib, selected_label)
              assert diffs[(ib, sf)] == pytest.approx(
                  results[("+", label, sf)], rel=1e-10, abs=1e-12
              )
              assert diffs[(ib, sf)] == pytest.approx(
                  -results[("-", label, sf)], rel=1e-10, abs=1e-12
              )
  
file_path: fairlearn/test/unit/reductions/moments/test_moments_control_features.py
imports: from test.unit.reductions.data_generators import loan_scenario_generator
  import pandas
  import pytest
  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, FalsePositiveRateParity, TruePositiveRateParity
label_desc: Use image node_id 4 for calling a global function with example usage: _selected_label_compare(moment, metric, selected_label) without return types