code: def test_feature_importance_validation():
      features = ["a", "b", "c"]
      feature_importance = pd.Series([0.3, 0.3, 0.4], index=features)
      feature_importance_with_null = pd.Series(
          [0.3, 0.3, None], index=features
      )
  
      assert_that(
          calling(validate_feature_importance).with_args(
              feature_importance.values, features
          ),
          raises(
              DeepchecksValueError,
              "feature_importance must be given as a pandas.Series where the index is feature names and the "
              "value is the calculated importance",
          ),
      )
  
      assert_that(
          calling(validate_feature_importance).with_args(
              feature_importance, ["a", "b", "d"]
          ),
          raises(
              DeepchecksValueError,
              "feature_importance index must be the feature names",
          ),
      )
  
      assert_that(
          calling(validate_feature_importance).with_args(
              feature_importance_with_null, features
          ),
          raises(
              DeepchecksValueError,
              "feature_importance must not contain null values",
          ),
      )
  
      assert_that(
          calling(validate_feature_importance).with_args(
              feature_importance * -1, features
          ),
          raises(
              DeepchecksValueError,
              "feature_importance must not contain negative values",
          ),
      )
  
      with pytest.warns(
          UserWarning,
          match="feature_importance does not sum to 1. Normalizing to 1.",
      ):
          normalized_feature_importance = validate_feature_importance(
              feature_importance * 2, features
          )
  
      assert_that(
          normalized_feature_importance.sum(), close_to(1, 0.0001)
      )
  
imports: import pandas
  import pytest
  from hamcrest import any_of, assert_that, calling, close_to, contains_exactly, contains_string, equal_to, has_length, is_, none, not_none, raises
  from sklearn.ensemble import AdaBoostClassifier
  from sklearn.linear_model import LinearRegression, LogisticRegression
  from sklearn.neural_network import MLPClassifier, MLPRegressor
  from sklearn.pipeline import Pipeline
  from deepchecks.core.errors import DeepchecksTimeoutError, DeepchecksValueError, ModelValidationError
  from deepchecks.tabular.dataset import Dataset
  from deepchecks.tabular.utils.feature_importance import _calculate_feature_importance, calculate_feature_importance_or_none, column_importance_sorter_df, column_importance_sorter_dict, validate_feature_importance
  from deepchecks.tabular.utils.task_inference import get_all_labels, infer_classes_from_model, infer_task_type_by_class_number, infer_task_type_by_labels
  from deepchecks.tabular.utils.task_type import TaskType
label_desc: Use image node_id 18 for calling a global function with example usage: test_feature_importance_validation() without return types