code: def add_estimator_to_pipeline(
      pipeline: Pipeline, estimator, name="actual_estimator"
  ):
      """Pipeline created before every cross-validation
  
      Parameters
      ----------
      pipeline : Pipeline
          [description]
      estimator : [type]
          [description]
      name : str, optional
          [description], by default "actual_estimator"
      """
      try:
          assert hasattr(pipeline._final_estimator, "predict")
          pipeline.replace_final_estimator(estimator, name=name)
      except Exception:
          pipeline.steps.append((name, estimator))
  
imports: import platform
  import warnings
  from copy import deepcopy
  from inspect import signature
  import imblearn.pipeline
  import sklearn.pipeline
  from sklearn.base import clone
  from sklearn.utils import _print_elapsed_time
  from sklearn.utils.metaestimators import available_if
  from sklearn.utils.validation import check_memory
  from pycaret.utils._show_versions import _get_deps_info
  from pycaret.utils.generic import get_all_object_vars_and_properties, variable_return
label_desc: Use image node_id 9 for calling a global function with example usage: add_estimator_to_pipeline(pipeline, estimator, name) without return types