code: def model_error_contribution(
      train_dataset: pd.DataFrame,
      train_scores: pd.Series,
      test_dataset: pd.DataFrame,
      test_scores: pd.Series,
      numeric_features: List,
      categorical_features: List,
      min_error_model_score=0.5,
      random_state=42,
  ) -> Tuple[pd.Series, pd.Series]:
      """Calculate features contributing to model error."""
      # Create and fit model to predict the per sample error
      error_model, new_feature_order = create_error_regression_model(
          numeric_features,
          categorical_features,
          random_state=random_state,
      )
      error_model.fit(train_dataset, y=train_scores)
  
      # Check if fitted model is good enough
      error_model_predicted = error_model.predict(test_dataset)
      error_model_score = r2_score(test_scores, error_model_predicted)
  
      # This check should be ignored if no information gained from the error model (low r2_score)
      if error_model_score < min_error_model_score:
          raise DeepchecksProcessError(
              f"Unable to train meaningful error model "
              f"(r^2 score: {format_number(error_model_score)})"
          )
      error_fi, _ = _calculate_feature_importance(
          error_model,
          Dataset(
              test_dataset,
              test_scores,
              cat_features=categorical_features,
          ),
          model_classes=None,
          observed_classes=None,
          task_type=TaskType.REGRESSION,
          permutation_kwargs={
              "random_state": random_state,
              "skip_messages": True,
          },
      )
      error_fi.index = new_feature_order
      error_fi.sort_values(ascending=False, inplace=True)
      return error_fi, error_model_predicted
  
imports: from typing import Any, Callable, Dict, Hashable, List, Optional, Tuple
  import numpy
  import pandas
  import plotly.express
  from category_encoders import TargetEncoder
  from sklearn.compose import ColumnTransformer
  from sklearn.ensemble import RandomForestRegressor
  from sklearn.impute import SimpleImputer
  from sklearn.metrics import r2_score
  from sklearn.pipeline import Pipeline
  from sklearn.tree import DecisionTreeRegressor
  from deepchecks import tabular
  from deepchecks.core.errors import DeepchecksProcessError
  from deepchecks.tabular import Dataset
  from deepchecks.tabular.utils.feature_importance import _calculate_feature_importance
  from deepchecks.tabular.utils.task_type import TaskType
  from deepchecks.utils.plot import colors
  from deepchecks.utils.strings import format_number, format_percent
label_desc: Use image node_id 1 for calling a global function with example usage: model_error_contribution(train_dataset, train_scores, test_dataset, test_scores, numeric_features, categorical_features, min_error_model_score, random_state) and returns: error_fi,  error_model_predicted