code: def get_group_and_individual_importances(
      term_groups_list, ebm, X, contributions=None
  ):
      """Returns a dict containing the importances of the groups in term_groups_list as well as
          all other EBM terms
  
      The dict will de sorted in descending order w.r.t. the importances
  
      Args:
          term_groups_list: A list of term groups, which are lists of term names or indices
              e.g. [["Feature 1", "Feature 2], ["Feature 3", "Feature 4"]]
          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:
         a dict where each entry is in the form 'term_name: term_importance'
      """
      if not isinstance(term_groups_list, list):
          raise ValueError("term_groups_list should be a list.")
      elif len(term_groups_list) == 0:
          raise ValueError(
              "term_groups_list should be a non-empty list."
          )
  
      if contributions is None:
          contributions = ebm.eval_terms(X)
  
      dict = {}
  
      for term in ebm.term_names_:
          dict[term] = compute_group_importance(
              [term], ebm, X, contributions
          )
  
      # If it's not a list of lists, we assume it's only one term group (e.g. list of strings or ints)
      if not isinstance(term_groups_list[0], list):
          group_name = _get_group_name(
              term_groups_list, ebm.term_names_
          )
          dict[group_name] = compute_group_importance(
              term_groups_list, ebm, X, contributions
          )
      else:
          for term_group in term_groups_list:
              group_name = _get_group_name(term_group, ebm.term_names_)
              dict[group_name] = compute_group_importance(
                  term_group, ebm, X, contributions
              )
  
      sorted_dict = {
          k: v
          for k, v in sorted(
              dict.items(), key=lambda item: item[1], reverse=True
          )
      }
      return sorted_dict
  
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 4 for calling a global function with example usage: get_group_and_individual_importances(term_groups_list, ebm, X, contributions) and returns: sorted_dict