code: def _available_if_estimator_has(attr):
      """Return a function to check if the sub-estimator(s) has(have) `attr`.
  
      Helper for Chain implementations.
      """
  
      def _check(self):
          if hasattr(self, "estimators_"):
              return all(hasattr(est, attr) for est in self.estimators_)
  
          if hasattr(self.estimator, attr):
              return True
  
          return False
  
      return available_if(_check)
  
imports: from abc import ABCMeta, abstractmethod
  from numbers import Integral
  import numpy
  import scipy.sparse
  from .base import BaseEstimator, ClassifierMixin, MetaEstimatorMixin, RegressorMixin, _fit_context, clone, is_classifier
  from .model_selection import cross_val_predict
  from .utils import Bunch, _print_elapsed_time, check_random_state
  from .utils._param_validation import HasMethods, StrOptions
  from .utils.metadata_routing import MetadataRouter, MethodMapping, _routing_enabled, process_routing
  from .utils.metaestimators import available_if
  from .utils.multiclass import check_classification_targets
  from .utils.parallel import Parallel, delayed
  from .utils.validation import _check_fit_params, check_is_fitted, has_fit_parameter
label_desc: Use image node_id 3 for calling a global function with example usage: _available_if_estimator_has(attr) and returns: available_if, False, all, True