code: def get_coef(estimator, attr="filters_", inverse_transform=False):
      """Retrieve the coefficients of an estimator ending with a Linear Model.
  
      This is typically useful to retrieve "spatial filters" or "spatial
      patterns" of decoding models :footcite:`HaufeEtAl2014`.
  
      Parameters
      ----------
      estimator : object | None
          An estimator from scikit-learn.
      attr : str
          The name of the coefficient attribute to retrieve, typically
          ``'filters_'`` (default) or ``'patterns_'``.
      inverse_transform : bool
          If True, returns the coefficients after inverse transforming them with
          the transformer steps of the estimator.
  
      Returns
      -------
      coef : array
          The coefficients.
  
      References
      ----------
      .. footbibliography::
      """
      # Get the coefficients of the last estimator in case of nested pipeline
      est = estimator
      while hasattr(est, "steps"):
          est = est.steps[-1][1]
  
      squeeze_first_dim = False
  
      # If SlidingEstimator, loop across estimators
      if hasattr(est, "estimators_"):
          coef = list()
          for this_est in est.estimators_:
              coef.append(get_coef(this_est, attr, inverse_transform))
          coef = np.transpose(coef)
          coef = coef[np.newaxis]  # fake a sample dimension
          squeeze_first_dim = True
      elif not hasattr(est, attr):
          raise ValueError(
              f"This estimator does not have a {attr} attribute:\n{est}"
          )
      else:
          coef = getattr(est, attr)
  
      if coef.ndim == 1:
          coef = coef[np.newaxis]
          squeeze_first_dim = True
  
      # inverse pattern e.g. to get back physical units
      if inverse_transform:
          if not hasattr(estimator, "steps") and not hasattr(
              est, "estimators_"
          ):
              raise ValueError(
                  "inverse_transform can only be applied onto pipeline estimators."
              )
          # The inverse_transform parameter will call this method on any
          # estimator contained in the pipeline, in reverse order.
          for inverse_func in _get_inverse_funcs(estimator)[::-1]:
              coef = inverse_func(coef)
  
      if squeeze_first_dim:
          coef = coef[0]
  
      return coef
  
imports: import datetime
  import numbers
  import numpy
  from ..fixes import BaseEstimator, _check_fit_params, _get_check_scoring
  from ..parallel import parallel_func
  from ..utils import verbose, warn
label_desc: Use image node_id 4 for calling a global function with example usage: get_coef(estimator, attr, inverse_transform) and returns: coef