code: def _estimator_has(attr):
      """Check if we can delegate a method to the underlying estimator.
  
      First, we check the fitted estimator if available, otherwise we
      check the unfitted estimator.
      """
      return lambda self: (
          hasattr(self.estimator_, attr)
          if hasattr(self, "estimator_")
          else hasattr(self.estimator, attr)
      )
  
imports: from copy import deepcopy
  from numbers import Integral, Real
  import numpy
  from ..base import BaseEstimator, MetaEstimatorMixin, _fit_context, clone
  from ..exceptions import NotFittedError
  from ..utils._param_validation import HasMethods, Interval, Options
  from ..utils._tags import _safe_tags
  from ..utils.metaestimators import available_if
  from ..utils.validation import _num_features, check_is_fitted, check_scalar
  from ._base import SelectorMixin, _get_feature_importances
label_desc: Use image node_id 2 for calling a global function with example usage: _estimator_has(attr) and returns: function