class_docstr: Defines the CounterfactualManager for generating counterfactuals
  from a model.
class_docstr_tok: ["Defines","the","CounterfactualManager","for","generating","counterfactuals","from","a","model","."]
docstr: Return the counterfactuals for a given point.
  
  :param query_id: The query id for finding the
                   counterfactual config.
  :type query_id: str
  :param data: The data point for which the counterfactuals
               need to be generated.
  :type data: Any
  :return: An object of type CounterfactualData with
           counterfactuals for the given data point.
  :rtype: CounterfactualData
code: def request_counterfactuals(self, query_id: str, data: Any):
      """Return the counterfactuals for a given point.
  
      :param query_id: The query id for finding the
                       counterfactual config.
      :type query_id: str
      :param data: The data point for which the counterfactuals
                   need to be generated.
      :type data: Any
      :return: An object of type CounterfactualData with
               counterfactuals for the given data point.
      :rtype: CounterfactualData
      """
      if not isinstance(data, pd.DataFrame):
          raise UserConfigValidationException(
              "Data is of type {0} but it must be "
              "a pandas DataFrame.".format(type(data))
          )
  
      if data.shape[0] > 1:
          raise UserConfigValidationException(
              "Only one row of data is allowed for "
              "counterfactual generation."
          )
  
      query_cf_config = None
      for cf_config in self._counterfactual_config_list:
          if cf_config.id == query_id:
              query_cf_config = cf_config
              break
  
      if query_cf_config is None:
          raise UserConfigValidationException(
              "No counterfactual config found for id {0}.".format(
                  query_id
              )
          )
  
      if not query_cf_config.feature_importance:
          counterfactual_obj = (
              query_cf_config.explainer.generate_counterfactuals(
                  data,
                  total_CFs=query_cf_config.total_CFs,
                  desired_class=query_cf_config.desired_class,
                  desired_range=query_cf_config.desired_range,
                  features_to_vary=query_cf_config.features_to_vary,
                  permitted_range=query_cf_config.permitted_range,
              )
          )
      else:
          counterfactual_obj = (
              query_cf_config.explainer.local_feature_importance(
                  data,
                  total_CFs=query_cf_config.total_CFs,
                  desired_class=query_cf_config.desired_class,
                  desired_range=query_cf_config.desired_range,
                  features_to_vary=query_cf_config.features_to_vary,
                  permitted_range=query_cf_config.permitted_range,
              )
          )
  
      # Validate the serialized output against schema
      schema = CounterfactualManager._get_counterfactual_schema(
          version=counterfactual_obj.metadata["version"]
      )
      jsonschema.validate(
          json.loads(counterfactual_obj.to_json()), schema
      )
  
      return self._get_counterfactual(
          query_cf_config, counterfactual_obj
      )
  
imports: import json
  import uuid
  import warnings
  from pathlib import Path
  from typing import Any, List, Optional, Union
  import dice_ml
  import jsonschema
  import numpy
  import pandas
  from dice_ml import Dice
  from dice_ml.counterfactual_explanations import CounterfactualExplanations
  from dice_ml.explainer_interfaces.explainer_base import ExplainerBase
  from raiutils.exceptions import UserConfigValidationException
  from raiutils.models import ModelTask
  from responsibleai._config.base_config import BaseConfig
  from responsibleai._data_validations import validate_train_test_categories
  from responsibleai._interfaces import CounterfactualData
  from responsibleai._internal.constants import CounterfactualManagerKeys, FileFormats, ListProperties, ManagerNames
  from responsibleai._tools.shared.state_directory_management import DirectoryManager
  from responsibleai.exceptions import DuplicateManagerConfigException, SchemaErrorException
  from responsibleai.managers.base_manager import BaseManager
  from responsibleai.utils import _find_features_having_missing_values, _measure_time
label_desc: Use image node_id 6 for calling the CounterfactualManager obj's underlying member method code with example usage: obj.request_counterfactuals(query_id, data) and returns: self