code: def validate_rai_insights(
      rai_insights,
      train_data,
      test_data,
      target_column,
      task_type,
      categorical_features=None,
      feature_range_keys=None,
      feature_columns=None,
      feature_metadata=None,
  ):
      pd.testing.assert_frame_equal(rai_insights.train, train_data)
      pd.testing.assert_frame_equal(rai_insights.test, test_data)
      assert rai_insights.target_column == target_column
      assert rai_insights.task_type == task_type
      assert rai_insights.categorical_features == (
          categorical_features or []
      )
      if feature_range_keys is not None:
          assert (
              feature_range_keys.sort()
              == list(rai_insights._feature_ranges[0].keys()).sort()
          )
      if feature_columns is not None:
          assert rai_insights._feature_columns == (
              feature_columns or []
          )
      if feature_metadata is not None:
          # mismatch between categorical_features passed in RAIInsights
          # constructor and the categorical_features set on the feature_metadata
          if (
              categorical_features is not None
              and feature_metadata.categorical_features is None
          ):
              feature_metadata.categorical_features = (
                  categorical_features
              )
          assert rai_insights._feature_metadata == feature_metadata
      assert target_column not in rai_insights._feature_columns
  
      if rai_insights.model is None:
          assert rai_insights._predict_output is None
          assert rai_insights._predict_proba_output is None
      else:
          assert rai_insights._predict_output is not None
          if task_type == ModelTask.CLASSIFICATION:
              assert rai_insights._predict_proba_output is not None
              assert isinstance(
                  rai_insights._predict_proba_output, np.ndarray
              )
              assert len(
                  rai_insights._predict_proba_output.tolist()[0]
              ) == len(rai_insights._classes)
  
      if task_type == ModelTask.CLASSIFICATION:
          classes = train_data[target_column].unique()
          classes.sort()
          np.testing.assert_array_equal(rai_insights._classes, classes)
  
imports: import os
  from pathlib import Path
  from tempfile import TemporaryDirectory
  import numpy
  import pandas
  import pytest
  from tests.common_utils import ADULT_CATEGORICAL_FEATURES_AFTER_DROP, ADULT_DROPPED_FEATURES, create_iris_data
  from rai_test_utils.datasets.tabular import create_binary_classification_dataset
  from rai_test_utils.models.lightgbm import create_lightgbm_classifier
  from rai_test_utils.models.sklearn import create_complex_classification_pipeline
  from raiutils.models import ModelTask
  from responsibleai import RAIInsights
  from responsibleai._internal.constants import ManagerNames, SerializationAttributes
  from responsibleai.feature_metadata import FeatureMetadata
label_desc: Use image node_id 2 for calling a global function with example usage: validate_rai_insights(rai_insights, train_data, test_data, target_column, task_type, categorical_features, feature_range_keys, feature_columns, feature_metadata) without return types