code: def test_signed_weights():
      eqo = EqualizedOdds()
      assert eqo.short_name == "EqualizedOdds"
  
      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
      eqo.load_data(X, Y, sensitive_features=A)
  
      events = ["label=False", "label=True"]
      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, 4000, 5000, 500, 100, 700, 900],
          index=midx,
          name=0,
      )
  
      lambda_a0_F = 2000 - 500
      lambda_a0_T = 4000 - 700
      num_a0_F = int(a0_threshold * num_samples_a0)
      num_a0_T = num_samples_a0 - num_a0_F
  
      lambda_a1_F = 1000 - 100
      lambda_a1_T = 5000 - 900
      num_a1_F = int(a1_threshold * num_samples_a1)
      num_a1_T = num_samples_a1 - num_a1_F
  
      sw_a0_F = (lambda_a0_F + lambda_a1_F) / (
          1 - sum(Y) / len(Y)
      ) - lambda_a0_F * (num_samples / num_a0_F)
      sw_a1_F = (lambda_a0_F + lambda_a1_F) / (
          1 - sum(Y) / len(Y)
      ) - lambda_a1_F * (num_samples / num_a1_F)
      sw_a0_T = (lambda_a0_T + lambda_a1_T) / (
          sum(Y) / len(Y)
      ) - lambda_a0_T * (num_samples / num_a0_T)
      sw_a1_T = (lambda_a0_T + lambda_a1_T) / (
          sum(Y) / len(Y)
      ) - lambda_a1_T * (num_samples / num_a1_T)
  
      w_a0_F = np.full(num_a0_F, sw_a0_F)
      w_a0_T = np.full(num_a0_T, sw_a0_T)
      w_a1_F = np.full(num_a1_F, sw_a1_F)
      w_a1_T = np.full(num_a1_T, sw_a1_T)
      expected = np.concatenate(
          (w_a0_F, w_a0_T, w_a1_F, w_a1_T), axis=None
      )
  
      signed_weights = eqo.signed_weights(lambda_vec)
      assert np.allclose(expected, signed_weights)
  
file_path: fairlearn/test/unit/reductions/moments/test_moments_equalized_odds.py
imports: import numpy
  import pandas
  from fairlearn.reductions import EqualizedOdds
  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