code: def test_counterfactual_manager_request_counterfactuals(
      self, feature_importance
  ):
      (
          X_train,
          X_test,
          y_train,
          y_test,
          feature_names,
          _,
      ) = create_iris_data()
  
      model = create_lightgbm_classifier(X_train, y_train)
      X_train["target"] = y_train
      X_test["target"] = y_test
  
      rai_insights = RAIInsights(
          model=model,
          train=X_train,
          test=X_test.iloc[0:10],
          target_column="target",
          task_type="classification",
      )
  
      rai_insights.counterfactual.add(
          total_CFs=10,
          desired_class=2,
          features_to_vary=[feature_names[0]],
          permitted_range={feature_names[0]: [2.0, 5.0]},
          feature_importance=feature_importance,
      )
      rai_insights.counterfactual.add(
          total_CFs=10,
          desired_class=1,
          features_to_vary=[feature_names[0]],
          permitted_range={feature_names[0]: [2.0, 5.0]},
          feature_importance=feature_importance,
      )
      rai_insights.counterfactual.compute()
  
      test_instance = X_test.iloc[0:1].drop("target", axis=1)
      query_id = (
          rai_insights.counterfactual._counterfactual_config_list[0].id
      )
      counterfactual_data = (
          rai_insights.counterfactual.request_counterfactuals(
              query_id, test_instance
          )
      )
  
      self._verify_counterfactual_data([counterfactual_data])
  
      test_instance = X_test.iloc[0:2].drop("target", axis=1)
      query_id = (
          rai_insights.counterfactual._counterfactual_config_list[1].id
      )
      with pytest.raises(
          UserConfigValidationException,
          match="Only one row of data is allowed for "
          "counterfactual generation.",
      ):
          rai_insights.counterfactual.request_counterfactuals(
              query_id, test_instance
          )
  
      test_instance = X_test.iloc[0:1].drop("target", axis=1)
      incorrect_query_id = "incorrect_query_id"
      with pytest.raises(
          UserConfigValidationException,
          match="No counterfactual config found for id {0}.".format(
              incorrect_query_id
          ),
      ):
          rai_insights.counterfactual.request_counterfactuals(
              incorrect_query_id, test_instance
          )
  
      test_instance = X_test.iloc[0:1].drop("target", axis=1).values
      query_id = (
          rai_insights.counterfactual._counterfactual_config_list[1].id
      )
      with pytest.raises(
          UserConfigValidationException,
          match="Data is of type <class 'numpy.ndarray'>"
          " but it must be a pandas DataFrame.",
      ):
          rai_insights.counterfactual.request_counterfactuals(
              query_id, test_instance
          )
  
file_path: responsible-ai-toolbox/responsibleai/tests/counterfactual/test_counterfactual_advanced_features.py
imports: import os
  import pytest
  from rai_test_utils.models.lightgbm import create_lightgbm_classifier
  from raiutils.exceptions import UserConfigValidationException
  from responsibleai import RAIInsights
  from responsibleai._interfaces import CounterfactualData
  from responsibleai._internal.constants import FileFormats
  from responsibleai._tools.shared.state_directory_management import DirectoryManager
  from ..common_utils import create_iris_data
label_desc: Use image node_id 4 for calling the TestCounterfactualAdvancedFeatures obj's underlying member method code with example usage: obj.test_counterfactual_manager_request_counterfactuals(feature_importance) without return types