code: def test_nearest_neighbor_match_by_group(generate_unmatched_data):
      df, features = generate_unmatched_data()
  
      psm = NearestNeighborMatch(
          replace=False, ratio=1.0, random_state=RANDOM_SEED
      )
  
      matched = psm.match_by_group(
          data=df,
          treatment_col=TREATMENT_COL,
          score_cols=[SCORE_COL],
          groupby_col=GROUP_COL,
      )
  
      assert sum(matched[TREATMENT_COL] == 0) == sum(
          matched[TREATMENT_COL] != 0
      )
  
file_path: causalml/tests/test_match.py
imports: import numpy
  import pandas
  import pytest
  from causalml.match import NearestNeighborMatch, MatchOptimizer
  from causalml.propensity import ElasticNetPropensityModel
  from .const import RANDOM_SEED, TREATMENT_COL, SCORE_COL, GROUP_COL
label_desc: Use image node_id 2 for calling a global function with example usage: test_nearest_neighbor_match_by_group(generate_unmatched_data) without return types