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: Validates the feature metadata.
docstr_tok: ["Validates","the","feature","metadata","."]
code: def _validate_feature_metadata(
      self, feature_metadata, train, task_type, model, target_column
  ):
      """Validates the feature metadata."""
      if feature_metadata is not None:
          if not isinstance(feature_metadata, FeatureMetadata):
              raise UserConfigValidationException(
                  "Expecting type FeatureMetadata but got "
                  f"{type(feature_metadata)}"
              )
  
          feature_names = list(
              train.drop(columns=[target_column]).columns
          )
          feature_metadata.validate_feature_metadata_with_user_features(
              feature_names
          )
  
          if task_type != ModelTask.FORECASTING:
              if feature_metadata.time_series_id_features:
                  raise UserConfigValidationException(
                      "The specified metadata time_series_id_features "
                      "is only supported for the forecasting task type."
                  )
  
              if feature_metadata.datetime_features:
                  raise UserConfigValidationException(
                      "The specified metadata datetime_features "
                      "is only supported for the forecasting task type."
                  )
          else:
              if (
                  feature_metadata.datetime_features
                  and len(feature_metadata.datetime_features) > 1
              ):
                  raise UserConfigValidationException(
                      "Only a single datetime feature is supported at "
                      "this point."
                  )
  
              self._ensure_time_column_available(
                  feature_metadata, feature_names, model
              )
  
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 12 for calling the RAIInsights obj's underlying member method code with example usage: obj._validate_feature_metadata(feature_metadata, train, task_type, model, target_column) without return types