class_docstr: Defines the CounterfactualManager for generating counterfactuals
  from a model.
class_docstr_tok: ["Defines","the","CounterfactualManager","for","generating","counterfactuals","from","a","model","."]
docstr: Computes the counterfactual examples by running the counterfactual
  configuration.
code: def compute(self):
      """Computes the counterfactual examples by running the counterfactual
      configuration."""
      print("Counterfactual")
      for cf_config in self._counterfactual_config_list:
          if not cf_config.is_computed:
              cf_config.is_computed = True
              try:
                  print(
                      "Current Status: Generating {0} counterfactuals"
                      " for {1} samples".format(
                          cf_config.total_CFs, len(self._test)
                      )
                  )
  
                  cf_config.explainer = self._create_diceml_explainer(
                      method=cf_config.method,
                      continuous_features=cf_config.continuous_features,
                  )
  
                  X_test = self._test.drop(
                      [self._target_column], axis=1
                  )
  
                  if not cf_config.feature_importance:
                      counterfactual_obj = cf_config.explainer.generate_counterfactuals(
                          X_test,
                          total_CFs=cf_config.total_CFs,
                          desired_class=cf_config.desired_class,
                          desired_range=cf_config.desired_range,
                          features_to_vary=cf_config.features_to_vary,
                          permitted_range=cf_config.permitted_range,
                      )
                  else:
                      counterfactual_obj = cf_config.explainer.global_feature_importance(
                          X_test,
                          total_CFs=cf_config.total_CFs,
                          desired_class=cf_config.desired_class,
                          desired_range=cf_config.desired_range,
                          features_to_vary=cf_config.features_to_vary,
                          permitted_range=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
                  )
  
                  cf_config.counterfactual_obj = counterfactual_obj
  
                  print(
                      "Current Status: Generated {0} counterfactuals"
                      " for {1} samples.".format(
                          cf_config.total_CFs, len(self._test)
                      )
                  )
              except Exception as e:
                  cf_config.has_computation_failed = True
                  cf_config.failure_reason = str(e)
                  raise e
  
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 5 for calling the CounterfactualManager obj's underlying member method code with example usage: obj.compute() without return types