code: def compute_group_importance(term_list, ebm, X, contributions=None):
      """Computes the importance of a group of terms.
  
      Args:
          term_list: A list of term names or indices
          ebm: A fitted EBM
          X (numpy array): Samples used to compute the group importance
          contributions (numpy array, optional): Contributions of all terms per X's row
  
      Returns:
          float: term_list's group importance
      """
      check_is_fitted(ebm, "has_fitted_")
  
      if contributions is None:
          contributions = ebm.eval_terms(X)
      ebm_term_names = ebm.term_names_
      term_group_indices = []
  
      for term in term_list:
          if isinstance(term, str):
              try:
                  term_group_indices.append(ebm_term_names.index(term))
              except ValueError:
                  raise ValueError(f"Term '{term}' not found.")
          elif isinstance(term, int) and 0 <= term < len(
              ebm_term_names
          ):
              term_group_indices.append(term)
          else:
              raise ValueError(
                  f"Term '{term}' is not a string or a valid integer."
              )
  
      if len(term_group_indices) == 0:
          raise ValueError(
              "term_list does not contain any valid terms."
          )
  
      # For multiclass we take the average of contributions per class
      # TODO this is consistent to what Interpret is doing but might be changed
      if hasattr(ebm, "classes_") and 2 < len(ebm.classes_):
          contributions = np.average(np.abs(contributions), axis=-1)
  
      abs_sum_per_row = np.empty(len(contributions), np.float64)
      for i in range(len(contributions)):
          sum = 0.0
          for j in term_group_indices:
              sum += contributions[i][j]
          abs_sum_per_row[i] = abs(sum)
  
      return np.average(abs_sum_per_row)
  
file_path: interpret/python/interpret-core/interpret/glassbox/_ebm/_research/_group_importance.py
imports: import numpy
  import pandas
  import plotly.express
  from sklearn.utils.validation import check_is_fitted
label_desc: Use image node_id 1 for calling a global function with example usage: compute_group_importance(term_list, ebm, X, contributions) and returns: np