code: def merge_categorical_shap_values(
      shap_df, onehot_dict=None, output_cols=None
  ):
      """
      Returns a new feature new shap values np.array
      where the shap values of onehotencoded categorical features have been
      added up.
  
      Args:
          shap_df(pd.DataFrame): dataframe of shap values with appropriate column names
          onehot_dict (dict): dict of features with lists for onehot-encoded variables,
               e.g. {'Fare': ['Fare'], 'Sex' : ['Sex_male', 'Sex_Female']}
  
      Returns:
          pd.DataFrame
      """
      onehot_cols = []
      for col_name, col_list in onehot_dict.items():
          if len(col_list) > 1:
              shap_df[col_name] = shap_df[col_list].sum(axis=1)
              onehot_cols.append(col_name)
      if output_cols is not None:
          return shap_df[output_cols]
      return shap_df[onehot_cols]
  
imports: from functools import partial
  import re
  from collections import Counter
  from typing import List, Union
  import warnings
  import numpy
  import pandas
  from pandas.api.types import is_numeric_dtype, is_categorical_dtype
  from dtreeviz.trees import ShadowDecTree
  from sklearn.metrics import make_scorer
  from sklearn.base import clone
  from sklearn.pipeline import Pipeline
  from sklearn.model_selection import KFold, StratifiedKFold
  from joblib import Parallel, delayed
label_desc: Use image node_id 14 for calling a global function with example usage: merge_categorical_shap_values(shap_df, onehot_dict, output_cols) and returns: shap_df, shap_df