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 the text feature importances.
  
  :param explanation: The explanation.
  :type explanation: shap.Explanation
  :return: The text importances and corresponding tokens.
  :rtype: tuple[list[str], list[float], float]
docstr_tok: ["Compute","the","text","feature","importances",".",":","param","explanation",":","The","explanation",".",":","type","explanation",":","shap.Explanation",":","return",":","The","text","importances","and","corresponding","tokens",".",":","rtype",":","tuple","[","list","[","str","]",",","list","[","float","]",",","float","]"]
code: def _compute_text_feature_importances(self, explanation):
      """Compute the text feature importances.
  
      :param explanation: The explanation.
      :type explanation: shap.Explanation
      :return: The text importances and corresponding tokens.
      :rtype: tuple[list[str], list[float], float]
      """
      text_feature_importances = []
      is_classif_task = self._is_classification_task
      if is_classif_task:
          for instance in explanation:
              text_feature_importance = TextFeatureImportance()
              text_feature_importance.localExplanations = (
                  instance.values.tolist()
              )
              text_feature_importance.text = instance.data
              text_feature_importances.append(text_feature_importance)
      elif self._task_type == ModelTask.QUESTION_ANSWERING:
          for i_start, i_end in zip(explanation[0], explanation[1]):
              text_feature_importance = TextFeatureImportance()
              text_feature_importance.localExplanations = [
                  i_start.values.tolist(),
                  i_end.values.tolist(),
              ]
              text_feature_importance.text = i_start.data
              text_feature_importance.baseValues = [
                  i_start.base_values.tolist(),
                  i_end.base_values.tolist(),
              ]
              text_feature_importances.append(text_feature_importance)
      else:
          raise ValueError(
              "Unknown task type: {}".format(self._task_type)
          )
      return text_feature_importances
  
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 11 for calling the ExplainerManager obj's underlying member method code with example usage: obj._compute_text_feature_importances(explanation) and returns: text_feature_importances