code: def test_demographic_parity_difference_weighted(agg_method):
      actual = demographic_parity_difference(
          y_t,
          y_p,
          sensitive_features=g_1,
          sample_weight=s_w,
          method=agg_method,
      )
  
      gm = MetricFrame(
          metrics=selection_rate,
          y_true=y_t,
          y_pred=y_p,
          sensitive_features=g_1,
          sample_params={"sample_weight": s_w},
      )
  
      assert actual == gm.difference(method=agg_method)
  
file_path: fairlearn/test/unit/metrics/test_fairness_metrics.py
imports: import pytest
  from fairlearn.metrics import MetricFrame, demographic_parity_difference, demographic_parity_ratio, equalized_odds_difference, equalized_odds_ratio, equal_opportunity_difference, equal_opportunity_ratio, false_positive_rate, selection_rate, true_positive_rate
  from .data_for_test import g_1, s_w, y_p, y_t
label_desc: Use image node_id 2 for calling a global function with example usage: test_demographic_parity_difference_weighted(agg_method) without return types