code: def test_append_group_importance():
      data = synthetic_regression()
      X = data["full"]["X"]
      y = data["full"]["y"]
      term_names = ["A", "B"]
  
      ebm = ExplainableBoostingRegressor()
      ebm.fit(X, y)
  
      # An exception should be raised when the EBM is not fitted
      non_fitted_ebm = ExplainableBoostingRegressor()
      with pytest.raises(NotFittedError):
          append_group_importance(term_names, non_fitted_ebm, X)
  
      # An exception should be raised when the explanation is not local
      local_exp = ebm.explain_local(X[:2])
      with pytest.raises(ValueError):
          append_group_importance(
              term_names, ebm, X, global_exp=local_exp
          )
  
      # An exception should be raised when none of the input terms is valid
      with pytest.raises(ValueError):
          append_group_importance(["Z", -1, 20], ebm, X)
  
      global_explanation = append_group_importance(term_names, ebm, X)
      assert (
          "A, B" in global_explanation._internal_obj["overall"]["names"]
      )
      assert (
          compute_group_importance(term_names, ebm, X)
          in global_explanation._internal_obj["overall"]["scores"]
      )
  
      global_explanation = append_group_importance(
          term_names, ebm, X, group_name="Comp 1"
      )
      assert (
          "Comp 1"
          in global_explanation._internal_obj["overall"]["names"]
      )
      assert (
          compute_group_importance(term_names, ebm, X)
          in global_explanation._internal_obj["overall"]["scores"]
      )
  
file_path: interpret/python/interpret-core/tests/glassbox/ebm/research/test_group_importance.py
imports: import pytest
  import warnings
  from sklearn.exceptions import NotFittedError
  from interpret.glassbox import ExplainableBoostingRegressor, ExplainableBoostingClassifier
  from ....tutils import synthetic_multiclass, synthetic_classification, synthetic_regression
  from interpret.glassbox._ebm._research._group_importance import _get_group_name
  from interpret.glassbox._ebm._research import compute_group_importance, append_group_importance, get_group_and_individual_importances, get_individual_importances, get_importance_per_top_groups
label_desc: Use image node_id 2 for calling a global function with example usage: test_append_group_importance() without return types