code: def split_pipeline(pipeline: Pipeline, verbose: int = 1):
      """Splits a sklearn or imblearn pipeline into a transformer pipeline and the final estimator.
  
      Args:
          pipeline (sklearn.Pipeline): a fitted pipeline with an estimator
              with .predict method as the last step.
          verbose: verbose output
  
      Returns:
          transformer_pipeline, estimator
  
      """
      if not safe_isinstance(
          pipeline,
          "sklearn.pipeline.Pipeline",
          "imblearn.pipeline.Pipeline",
      ):
          raise ValueError(
              f"pipeline should either be an sklearn or an imblearn pipeline, but you passed {pipeline}!"
          )
  
      assert hasattr(pipeline.steps[-1][1], "predict"), (
          "When passing an sklearn.Pipeline, the last step of the pipeline should be a model, "
          f"but {pipeline.steps[-1][1]} does not have a .predict() function!"
      )
  
      if verbose:
          print("splitting pipeline...", flush=True)
          skipped_transforms = [
              name
              for name, transform in pipeline.steps[:-1]
              if not hasattr(transform, "transform")
          ]
          if skipped_transforms:
              print(
                  f"Skipping the following steps that lack a .transform() method: {', '.join(skipped_transforms)}...",
                  flush=True,
              )
  
      transform_steps = [
          (name, transform)
          for name, transform in pipeline.steps[:-1]
          if hasattr(transform, "transform")
      ]
      if transform_steps:
          transformer_pipeline = Pipeline(transform_steps)
      else:
          from sklearn.preprocessing import FunctionTransformer
  
          transformer_pipeline = Pipeline(
              [("identity", FunctionTransformer())]
          )
      estimator = pipeline.steps[-1][1]
  
      return transformer_pipeline, estimator
  
imports: from functools import partial
  import re
  from collections import Counter
  from typing import List, Union
  import warnings
  import numpy
  import pandas
  from pandas.api.types import is_numeric_dtype, is_categorical_dtype
  from dtreeviz.trees import ShadowDecTree
  from sklearn.metrics import make_scorer
  from sklearn.base import clone
  from sklearn.pipeline import Pipeline
  from sklearn.model_selection import KFold, StratifiedKFold
  from joblib import Parallel, delayed
label_desc: Use image node_id 7 for calling a global function with example usage: split_pipeline(pipeline, verbose) and returns: transformer_pipeline,  estimator