code: def test_class_imbalance():
      prot_attr = pd.Series([1, 1, 1, 1, 0, 0, 0], name="sex")
      y = pd.Series(
          np.random.random(7), index=prot_attr
      )  # y values are irrelevant
      sample_weight = np.array([1, 2, 3, 4, 3, 2, 1])
      assert (
          class_imbalance(y, sample_weight=sample_weight) == -0.25
      )  # -4/16
      assert (
          class_imbalance(y, priv_group=0, sample_weight=sample_weight)
          == 0.25
      )
  
imports: from functools import partial
  import numpy
  import pandas
  import pytest
  from numpy.testing import assert_almost_equal
  from sklearn.linear_model import LogisticRegression
  from aif360.datasets import AdultDataset
  from aif360.sklearn.datasets import fetch_adult
  from aif360.metrics import ClassificationMetric
  from aif360.sklearn.metrics import consistency_score, specificity_score, selection_rate, base_rate, smoothed_base_rate, generalized_fpr, generalized_fnr, disparate_impact_ratio, statistical_parity_difference, equal_opportunity_difference, average_odds_difference, average_predictive_value_difference, average_odds_error, smoothed_edf, df_bias_amplification, generalized_entropy_error, between_group_generalized_entropy_error, class_imbalance, kl_divergence, conditional_demographic_disparity, intersection, one_vs_rest, make_scorer
label_desc: Use image node_id 19 for calling a global function with example usage: test_class_imbalance() without return types