code: def test_signed_weights():
      dp = DemographicParity()
      assert dp.short_name == "DemographicParity"
  
      num_samples_a0 = 10
      num_samples_a1 = 30
      num_samples = num_samples_a0 + num_samples_a1
  
      a0_threshold = 0.2
      a1_threshold = 0.7
  
      a0_label = 0xDEAD
      a1_label = 0xBEEF
  
      X, Y, A = simple_binary_threshold_data(
          num_samples_a0,
          num_samples_a1,
          a0_threshold,
          a1_threshold,
          a0_label,
          a1_label,
      )
  
      # Load up the (rigged) data
      dp.load_data(X, Y, sensitive_features=A)
  
      events = ["all"]
      signs = ["+", "-"]
      labels = [a0_label, a1_label]
      midx = pd.MultiIndex.from_product(
          [signs, events, labels], names=[_SIGN, _EVENT, _GROUP_ID]
      )
  
      lambda_vec = pd.Series([2000, 1000, 500, 100], index=midx, name=0)
      lambda_a0 = 2000 - 500
      lambda_a1 = 1000 - 100
  
      sw_a0 = (lambda_a0 + lambda_a1) - lambda_a0 * (
          num_samples / num_samples_a0
      )
      sw_a1 = (lambda_a0 + lambda_a1) - lambda_a1 * (
          num_samples / num_samples_a1
      )
  
      w_a0 = np.full(num_samples_a0, sw_a0)
      w_a1 = np.full(num_samples_a1, sw_a1)
      expected = np.concatenate((w_a0, w_a1), axis=None)
  
      signed_weights = dp.signed_weights(lambda_vec)
      assert np.array_equal(expected, signed_weights)
  
file_path: fairlearn/test/unit/reductions/moments/test_moments_demographic_parity.py
imports: import numpy
  import pandas
  from fairlearn.reductions import DemographicParity
  from fairlearn.reductions._moments.moment import _EVENT, _GROUP_ID, _SIGN
  from .data_generator import simple_binary_threshold_data
label_desc: Use image node_id 4 for calling a global function with example usage: test_signed_weights() without return types