code: def validate_causal(
      rai_insights,
      data,
      target_column,
      treatment_features,
      max_cat_expansion,
  ):
      if (
          rai_insights.task_type == ModelTask.CLASSIFICATION
          and len(np.unique(data[target_column])) > 2
      ):
          with pytest.raises(
              UserConfigValidationException,
              match="Multiclass classification isn't supported",
          ):
              rai_insights.causal.add(
                  treatment_features,
                  nuisance_model="automl",
                  upper_bound_on_cat_expansion=max_cat_expansion,
              )
              rai_insights.causal.compute()
          _check_causal_properties(
              rai_insights.causal.list(), expected_causal_effects=0
          )
          return
  
      # Add the first configuration
      rai_insights.causal.add(
          treatment_features,
          nuisance_model="automl",
          upper_bound_on_cat_expansion=max_cat_expansion,
      )
      rai_insights.compute()
  
      results = rai_insights.causal.get()
      assert results is not None
      assert isinstance(results, list)
      assert len(results) == 1
      _check_causal_result(results[0])
  
      _check_causal_properties(
          rai_insights.causal.list(), expected_causal_effects=1
      )
  
      results = rai_insights.causal.get_data()
      assert results is not None
      assert isinstance(results, list)
      assert len(results) == 1
      _check_causal_result(results[0], is_serialized=True)
  
      # Add the second configuration
      rai_insights.causal.add(
          treatment_features, nuisance_model="linear"
      )
      rai_insights.compute()
      results = rai_insights.causal.get()
      assert results is not None
      assert isinstance(results, list)
      assert len(results) == 2
  
      _check_causal_properties(
          rai_insights.causal.list(), expected_causal_effects=2
      )
  
      # Add a bad configuration for nuisance_model
      with pytest.raises(UserConfigValidationException):
          rai_insights.causal.add(
              treatment_features, nuisance_model="fake_model"
          )
  
      # Add a bad configuration for heterogeneity_model
      with pytest.raises(UserConfigValidationException):
          rai_insights.causal.add(
              treatment_features, heterogeneity_model="fake_model"
          )
  
imports: import numpy
  import pandas
  import pytest
  from econml.solutions.causal_analysis._causal_analysis import CausalAnalysis
  from raiutils.exceptions import UserConfigValidationException
  from raiutils.models import ModelTask
  from responsibleai._interfaces import CausalConfig, CausalData, CausalPolicy, CausalPolicyGains, CausalPolicyTreeInternal, CausalPolicyTreeLeaf
  from responsibleai._internal.constants import CausalManagerKeys, ListProperties, ManagerNames
  from responsibleai._tools.causal.causal_result import CausalResult
label_desc: Use image node_id 1 for calling a global function with example usage: validate_causal(rai_insights, data, target_column, treatment_features, max_cat_expansion) without return types