class_docstr: Defines the ExplainerManager for explaining a text-based model.
class_docstr_tok: ["Defines","the","ExplainerManager","for","explaining","a","text-based","model","."]
docstr: Compute global feature importances.
  
  :param explanation: The explanation.
  :type explanation: shap.Explanation
  :return: The feature names, scores, and intercept.
  :rtype: tuple[list[str], list[float], float]
docstr_tok: ["Compute","global","feature","importances",".",":","param","explanation",":","The","explanation",".",":","type","explanation",":","shap.Explanation",":","return",":","The","feature","names",",","scores",",","and","intercept",".",":","rtype",":","tuple","[","list","[","str","]",",","list","[","float","]",",","float","]"]
code: def _compute_global_importances(self, explanation):
      """Compute global feature importances.
  
      :param explanation: The explanation.
      :type explanation: shap.Explanation
      :return: The feature names, scores, and intercept.
      :rtype: tuple[list[str], list[float], float]
      """
      is_classif_task = self._is_classification_task
      if is_classif_task:
          global_exp = explanation[:, :, :].mean(0)
          features = convert_to_list(global_exp.feature_names)
          scores = convert_to_list(np.abs(global_exp.values).mean(1))
          intercept = global_exp.base_values.mean(0)
      elif self._task_type == ModelTask.QUESTION_ANSWERING:
          flattened_start_features = explanation[
              0
          ]._flatten_feature_names()
          flattened_end_features = explanation[
              1
          ]._flatten_feature_names()
          scores = []
          features = []
          for key in flattened_start_features.keys():
              features.append(key)
              token_importances = []
              for importances_start, importances_end in zip(
                  flattened_start_features[key],
                  flattened_end_features[key],
              ):
                  abs_start_imps = np.abs(importances_start)
                  abs_end_imps = np.abs(importances_end)
                  importances = (abs_start_imps + abs_end_imps) / 2
                  mean_importances = np.mean(importances)
                  token_importances.append(mean_importances)
              scores.append(np.mean(token_importances))
              start_base_values = explanation[0].base_values
              end_base_values = explanation[1].base_values
              base_values = [
                  sbv.mean() + ebv.mean() / 2
                  for sbv, ebv in zip(
                      start_base_values, end_base_values
                  )
              ]
              intercept = sum(base_values) / len(base_values)
      else:
          raise ValueError(
              "Unknown task type: {}".format(self._task_type)
          )
      return features, scores, intercept
  
imports: import json
  import pickle
  import warnings
  from pathlib import Path
  from typing import Any, List, Optional
  import numpy
  import pandas
  import shap
  from raiutils.data_processing import convert_to_list
  from responsibleai._interfaces import FeatureImportance, ModelExplanationData, PrecomputedExplanations, TextFeatureImportance
  from responsibleai._internal.constants import ExplainerManagerKeys
  from responsibleai._internal.constants import ListProperties, ManagerNames, Metadata
  from responsibleai._tools.shared.state_directory_management import DirectoryManager
  from responsibleai.exceptions import UserConfigValidationException
  from responsibleai.managers.base_manager import BaseManager
  from responsibleai_text.common.constants import ModelTask, QuestionAnsweringFields, Tokens
  from responsibleai_text.utils.question_answering import QAPredictor
label_desc: Use image node_id 10 for calling the ExplainerManager obj's underlying member method code with example usage: obj._compute_global_importances(explanation) and returns: features,  scores,  intercept