code: def validate_rai_text_insights(
      rai_text_insights, classes, test_data, target_column, task_type
  ):
      pd.testing.assert_frame_equal(rai_text_insights.test, test_data)
      assert rai_text_insights.target_column == target_column
      assert rai_text_insights.task_type == task_type
      explanation = rai_text_insights.explainer.get()
      assert explanation is None or isinstance(explanation, list)
      explanation_data = rai_text_insights.explainer.get_data()
      assert explanation_data is None or isinstance(
          explanation_data, list
      )
      error_analysis_data = rai_text_insights.error_analysis.get_data()
      assert error_analysis_data is None or isinstance(
          error_analysis_data, list
      )
      if task_type == ModelTask.TEXT_CLASSIFICATION:
          np.testing.assert_array_equal(
              rai_text_insights._classes, classes
          )
          if explanation_data:
              exp_data = explanation_data[0].precomputedExplanations
              validate_global_importances(exp_data)
              local_data = exp_data.textFeatureImportance
              num_rows = len(test_data)
              assert len(local_data) == num_rows
              local_importances = local_data[0].localExplanations
              text = local_data[0].text
              assert len(local_importances) == len(text)
          if error_analysis_data:
              root_node = error_analysis_data[0].tree[0]
              # assert there were some successful predictions as sanity check
              assert root_node["error"] < root_node["size"]
      if task_type == ModelTask.QUESTION_ANSWERING:
          if explanation_data:
              exp_data = explanation_data[0].precomputedExplanations
              validate_global_importances(exp_data)
              local_data = exp_data.textFeatureImportance
              num_rows = len(test_data)
              assert len(local_data) == num_rows
              local_importances = local_data[0].localExplanations
              text = local_data[0].text
              base_values = local_data[0].baseValues
              assert len(local_importances) == 2
              assert len(local_importances[0]) == len(text)
              assert len(base_values) == 2
              assert len(base_values[0]) == len(text)
  
imports: import numpy
  import pandas
  from responsibleai_text import ModelTask
label_desc: Use image node_id 2 for calling a global function with example usage: validate_rai_text_insights(rai_text_insights, classes, test_data, target_column, task_type) without return types