code: def get_feature_importances(estimator):
      """Retrieve feature importance from a fitted estimator"""
  
      importances = getattr(estimator, "feature_importances_", None)
  
      coef_ = getattr(estimator, "coef_", None)
  
      if coef_ is not None:
          if estimator.coef_.ndim == 1:
              importances = np.abs(coef_)
  
          else:
              importances = np.linalg.norm(
                  coef_, axis=0, ord=len(estimator.coef_)
              )
  
          importances = list(importances)
  
      return importances
  
imports: import numpy
  import pandas
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.utils.validation import check_is_fitted
  from feature_engine._base_transformers.mixins import GetFeatureNamesOutMixin
  from feature_engine._variable_handling.variable_type_selection import _filter_out_variables_not_in_dataframe
  from feature_engine.dataframe_checks import _check_X_matches_training_df, check_X
  from feature_engine.tags import _return_tags
label_desc: Use image node_id 1 for calling a global function with example usage: get_feature_importances(estimator) and returns: importances