code: def _estimator_has(attr):
      """Check if we can delegate a method to the underlying estimator.
  
      First, we check the first fitted estimator if available, otherwise we
      check the estimator attribute.
      """
  
      def check(self):
          if hasattr(self, "estimators_"):
              return hasattr(self.estimators_[0], attr)
          elif self.estimator is not None:
              return hasattr(self.estimator, attr)
          else:  # TODO(1.4): Remove when the base_estimator deprecation cycle ends
              return hasattr(self.base_estimator, attr)
  
      return check
  
imports: import itertools
  import numbers
  from abc import ABCMeta, abstractmethod
  from functools import partial
  from numbers import Integral
  from warnings import warn
  import numpy
  from ..base import ClassifierMixin, RegressorMixin, _fit_context
  from ..metrics import accuracy_score, r2_score
  from ..tree import DecisionTreeClassifier, DecisionTreeRegressor
  from ..utils import check_random_state, column_or_1d, indices_to_mask
  from ..utils._param_validation import HasMethods, Interval, RealNotInt, StrOptions
  from ..utils._tags import _safe_tags
  from ..utils.metaestimators import available_if
  from ..utils.multiclass import check_classification_targets
  from ..utils.parallel import Parallel, delayed
  from ..utils.random import sample_without_replacement
  from ..utils.validation import _check_sample_weight, check_is_fitted, has_fit_parameter
  from ._base import BaseEnsemble, _partition_estimators
label_desc: Use image node_id 8 for calling a global function with example usage: _estimator_has(attr) and returns: check, hasattr, hasattr, hasattr