class_docstr: Defines the CounterfactualManager for generating counterfactuals
  from a model.
class_docstr_tok: ["Defines","the","CounterfactualManager","for","generating","counterfactuals","from","a","model","."]
docstr: Load the CounterfactualManager from the given path.
  
  :param path: The directory path to load the CounterfactualManager from.
  :type path: str
  :param rai_insights: The loaded parent RAIInsights.
  :type rai_insights: RAIInsights
  :return: The CounterfactualManager manager after loading.
  :rtype: CounterfactualManager
code: def _load(path, rai_insights):
      """Load the CounterfactualManager from the given path.
  
      :param path: The directory path to load the CounterfactualManager from.
      :type path: str
      :param rai_insights: The loaded parent RAIInsights.
      :type rai_insights: RAIInsights
      :return: The CounterfactualManager manager after loading.
      :rtype: CounterfactualManager
      """
      inst = CounterfactualManager.__new__(CounterfactualManager)
  
      # Rehydrate model analysis data
      inst.__dict__[CounterfactualManager._MODEL] = rai_insights.model
      inst.__dict__[CounterfactualManager._TRAIN] = rai_insights.train
      inst.__dict__[CounterfactualManager._TEST] = rai_insights.test
      inst.__dict__[
          CounterfactualManager._TARGET_COLUMN
      ] = rai_insights.target_column
      inst.__dict__[
          CounterfactualManager._TASK_TYPE
      ] = rai_insights.task_type
      inst.__dict__[
          CounterfactualManager._CATEGORICAL_FEATURES
      ] = rai_insights.categorical_features
  
      inst.__dict__[
          CounterfactualManager._COUNTERFACTUAL_CONFIG_LIST
      ] = []
  
      # DirectoryManager.ensure_dir_exists(path)
      all_cf_dirs = DirectoryManager.list_sub_directories(path)
      for counterfactual_config_dir in all_cf_dirs:
          directory_manager = DirectoryManager(
              parent_directory_path=path,
              sub_directory_name=counterfactual_config_dir,
          )
  
          counterfactual_config = CounterfactualConfig.load_config(
              directory_manager.get_config_directory()
          )
  
          counterfactual_config.load_result(
              directory_manager.get_data_directory()
          )
  
          counterfactual_config.load_explainer(
              directory_manager.get_generators_directory()
          )
  
          if counterfactual_config.explainer is None:
              explainer_load_err = (
                  "ERROR-LOADING-COUNTERFACTUAL-EXPLAINER: "
                  "There was an error loading the "
                  "counterfactual explainer model. "
                  "Retraining the counterfactual "
                  "explainer."
              )
              warnings.warn(explainer_load_err)
              counterfactual_config.explainer = (
                  inst._create_diceml_explainer(
                      counterfactual_config.method,
                      counterfactual_config.continuous_features,
                  )
              )
  
          if counterfactual_config.counterfactual_obj is not None:
              # Validate the serialized output against schema
              schema = CounterfactualManager._get_counterfactual_schema(
                  version=counterfactual_config.counterfactual_obj.metadata[
                      "version"
                  ]
              )
              jsonschema.validate(
                  json.loads(
                      counterfactual_config.counterfactual_obj.to_json()
                  ),
                  schema,
              )
  
          inst.__dict__[
              CounterfactualManager._COUNTERFACTUAL_CONFIG_LIST
          ].append(counterfactual_config)
  
      return inst
  
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 14 for calling the CounterfactualManager obj's underlying member method code with example usage: obj._load(path, rai_insights) and returns: inst