class_docstr: Defines the top-level Model Analysis API.
  Use RAIInsights to analyze errors, explain the most important
  features, compute counterfactuals and run causal analysis in a
  single API.
class_docstr_tok: ["Defines","the","top-level","Model","Analysis","API",".","Use","RAIInsights","to","analyze","errors",",","explain","the","most","important","features",",","compute","counterfactuals","and","run","causal","analysis","in","a","single","API","."]
docstr: Consolidates the categorical features.
  
  Originally, only the RAIInsights constructor accepted
  categorical_features. Later on, feature_metadata was added as an
  argument that also includes categorical_features.
  This method consolidates them or raises an exception if it is not
  possible. The resulting categorical features should be set on the
  self._feature_metadata object. Eventually, the categorical_features
  argument on the RAIInsights constructor will be removed at which
  point this method can be removed as well.
  
  :param categorical_features: the categorical features from the
      RAIInsights constructor
  :type categorical_features: Optional[List[str]]
  :param feature_metadata: the feature metadata specified which may
      include information on categorical features
  :type feature_metadata: Optional[FeatureMetadata]
docstr_tok: ["Consolidates","the","categorical","features",".","Originally",",","only","the","RAIInsights","constructor","accepted","categorical_features",".","Later","on",",","feature_metadata","was","added","as","an","argument","that","also","includes","categorical_features",".","This","method","consolidates","them","or","raises","an","exception","if","it","is","not","possible",".","The","resulting","categorical","features","should","be","set","on","the","self._feature_metadata","object",".","Eventually",",","the","categorical_features","argument","on","the","RAIInsights","constructor","will","be","removed","at","which","point","this","method","can","be","removed","as","well",".",":","param","categorical_features",":","the","categorical","features","from","the","RAIInsights","constructor",":","type","categorical_features",":","Optional","[","List","[","str","]","]",":","param","feature_metadata",":","the","feature","metadata","specified","which","may","include","information","on","categorical","features",":","type","feature_metadata",":","Optional","[","FeatureMetadata","]"]
code: def _consolidate_categorical_features(
      self,
      categorical_features: Optional[List[str]],
      feature_metadata: Optional[FeatureMetadata],
  ):
      """Consolidates the categorical features.
  
      Originally, only the RAIInsights constructor accepted
      categorical_features. Later on, feature_metadata was added as an
      argument that also includes categorical_features.
      This method consolidates them or raises an exception if it is not
      possible. The resulting categorical features should be set on the
      self._feature_metadata object. Eventually, the categorical_features
      argument on the RAIInsights constructor will be removed at which
      point this method can be removed as well.
  
      :param categorical_features: the categorical features from the
          RAIInsights constructor
      :type categorical_features: Optional[List[str]]
      :param feature_metadata: the feature metadata specified which may
          include information on categorical features
      :type feature_metadata: Optional[FeatureMetadata]
      """
      consolidated_categorical_features = []
      if categorical_features is not None:
          warnings.warn(
              "The categorical_features argument on the "
              "RAIInsights constructor is deprecated and will "
              "be removed after version 0.26. Please provide "
              "categorical features via the feature_metadata "
              "argument instead."
          )
      if feature_metadata is None:
          # initialize to avoid having to keep checking if it is None
          feature_metadata = FeatureMetadata()
      if feature_metadata.categorical_features is None:
          if categorical_features is None:
              consolidated_categorical_features = []
          else:
              consolidated_categorical_features = categorical_features
      else:
          if categorical_features is None:
              consolidated_categorical_features = (
                  feature_metadata.categorical_features
              )
          else:
              # Both are specified. Raise an exception if they don't match.
              if set(categorical_features) == set(
                  feature_metadata.categorical_features
              ):
                  consolidated_categorical_features = (
                      categorical_features
                  )
              else:
                  raise UserConfigValidationException(
                      "The categorical_features provided via the "
                      "RAIInsights constructor and the categorical_features "
                      "provided via the feature_metadata argument do not "
                      "match."
                  )
      # set the consolidated result on both fields uniformly
      self.categorical_features = consolidated_categorical_features
      self._feature_metadata = feature_metadata
      self._feature_metadata.categorical_features = (
          consolidated_categorical_features
      )
  
imports: import json
  import pickle
  import warnings
  from enum import Enum
  from pathlib import Path
  from typing import Any, List, Optional, Union
  import numpy
  import pandas
  from erroranalysis._internal.cohort_filter import FilterDataWithCohortFilters
  from erroranalysis._internal.process_categoricals import process_categoricals
  from raiutils.data_processing import convert_to_list
  from raiutils.exceptions import SystemErrorException, UserConfigValidationException
  from raiutils.models import Forecasting, ModelTask, SKLearn
  from responsibleai._interfaces import Dataset, RAIInsightsData, TabularDatasetMetadata
  from responsibleai._internal._forecasting_wrappers import _wrap_model
  from responsibleai._internal.constants import FileFormats, ManagerNames, Metadata, SerializationAttributes
  from responsibleai.feature_metadata import FeatureMetadata
  from responsibleai.managers.causal_manager import CausalManager
  from responsibleai.managers.counterfactual_manager import CounterfactualManager
  from responsibleai.managers.data_balance_manager import DataBalanceManager
  from responsibleai.managers.error_analysis_manager import ErrorAnalysisManager
  from responsibleai.managers.explainer_manager import ExplainerManager
  from responsibleai.rai_insights.rai_base_insights import RAIBaseInsights
label_desc: Use image node_id 5 for calling the RAIInsights obj's underlying member method code with example usage: obj._consolidate_categorical_features(categorical_features, feature_metadata) without return types