code: def _estimator_has(attr):
      """Check if we can delegate a method to the underlying estimator.
  
      First, we check the first fitted final estimator if available, otherwise we
      check the unfitted final estimator.
      """
      return lambda self: (
          hasattr(self.final_estimator_, attr)
          if hasattr(self, "final_estimator_")
          else hasattr(self.final_estimator, attr)
      )
  
imports: from abc import ABCMeta, abstractmethod
  from copy import deepcopy
  from numbers import Integral
  import numpy
  import scipy.sparse
  from ..base import ClassifierMixin, RegressorMixin, TransformerMixin, _fit_context, clone, is_classifier, is_regressor
  from ..exceptions import NotFittedError
  from ..linear_model import LogisticRegression, RidgeCV
  from ..model_selection import check_cv, cross_val_predict
  from ..preprocessing import LabelEncoder
  from ..utils import Bunch
  from ..utils._estimator_html_repr import _VisualBlock
  from ..utils._param_validation import HasMethods, StrOptions
  from ..utils.metadata_routing import _raise_for_unsupported_routing, _RoutingNotSupportedMixin
  from ..utils.metaestimators import available_if
  from ..utils.multiclass import check_classification_targets, type_of_target
  from ..utils.parallel import Parallel, delayed
  from ..utils.validation import _check_feature_names_in, _check_response_method, check_is_fitted, column_or_1d
  from ._base import _BaseHeterogeneousEnsemble, _fit_single_estimator
label_desc: Use image node_id 1 for calling a global function with example usage: _estimator_has(attr) and returns: function