class_docstr: Defines the top-level RAITextInsights API.
  
  Use RAITextInsights to assess text machine learning models in a
  single API.
class_docstr_tok: ["Defines","the","top-level","RAITextInsights","API",".","Use","RAITextInsights","to","assess","text","machine","learning","models","in","a","single","API","."]
code: def compute_question_answering_metrics(
      self, selection_indexes, question_answering_cache
  ):
      dashboard_dataset = self.get_data().dataset
      true_y = dashboard_dataset.true_y
      predicted_y = dashboard_dataset.predicted_y
      all_cohort_metrics = []
      for cohort_indices in selection_indexes:
          key = ",".join([str(cid) for cid in cohort_indices])
          if key in question_answering_cache:
              all_cohort_metrics.append(question_answering_cache[key])
              continue
          true_y_cohort = [
              true_y[cohort_index] for cohort_index in cohort_indices
          ]
          predicted_y_cohort = [
              predicted_y[cohort_index]
              for cohort_index in cohort_indices
          ]
          f1_score = []
          for cohort_index in cohort_indices:
              f1_score.append(
                  self.compute_f1(
                      predicted_y[cohort_index], true_y[cohort_index]
                  )
              )
          try:
              exact_match = evaluate.load("exact_match")
              exact_match_results = exact_match.compute(
                  predictions=predicted_y_cohort,
                  references=true_y_cohort,
              )
              rouge = evaluate.load("rouge")
              rouge_results = rouge.compute(
                  predictions=predicted_y_cohort,
                  references=true_y_cohort,
              )
              bleu = evaluate.load("bleu")
              bleu_results = bleu.compute(
                  predictions=predicted_y_cohort,
                  references=true_y_cohort,
              )
              meteor = evaluate.load("meteor")
              meteor_results = meteor.compute(
                  predictions=predicted_y_cohort,
                  references=true_y_cohort,
              )
              bert_score = evaluate.load("bertscore")
              bert_score_results = bert_score.compute(
                  predictions=predicted_y_cohort,
                  references=true_y_cohort,
                  model_type="distilbert-base-uncased",
              )
              bert_f1_score = np.mean(bert_score_results["f1"])
              all_cohort_metrics.append(
                  [
                      exact_match_results["exact_match"],
                      np.mean(f1_score),
                      meteor_results["meteor"],
                      bleu_results["bleu"],
                      bert_f1_score,
                      rouge_results["rougeL"],
                  ]
              )
          except ValueError:
              all_cohort_metrics.append([0, 0, 0, 0, 0, 0])
      return all_cohort_metrics
  
imports: import json
  import logging
  import pickle
  import warnings
  from enum import Enum
  from pathlib import Path
  from typing import Any, List, Optional, Union
  import numpy
  import pandas
  from ml_wrappers import wrap_model
  from erroranalysis._internal.cohort_filter import FilterDataWithCohortFilters
  from raiutils.data_processing import convert_to_list, serialize_json_safe
  from raiutils.models import SKLearn, is_classifier
  from responsibleai._interfaces import Dataset, RAIInsightsData
  from responsibleai._internal.constants import ManagerNames, Metadata, SerializationAttributes
  from responsibleai.exceptions import UserConfigValidationException
  from responsibleai.feature_metadata import FeatureMetadata
  from responsibleai.rai_insights.rai_base_insights import RAIBaseInsights
  from responsibleai_text.common.constants import ModelTask
  from responsibleai_text.managers.error_analysis_manager import ErrorAnalysisManager
  from responsibleai_text.managers.explainer_manager import ExplainerManager
  from responsibleai_text.utils.feature_extractors import extract_features, get_text_columns
label_desc: Use image node_id 25 for calling the RAITextInsights obj's underlying member method code with example usage: obj.compute_question_answering_metrics(selection_indexes, question_answering_cache) and returns: all_cohort_metrics