code: def _fit_stage_componentwise(
      X, residuals, sample_weight, **fit_params
  ):  # pylint: disable=unused-argument
      """Fit component-wise weighted least squares model"""
      n_features = X.shape[1]
  
      base_learners = []
      error = np.empty(n_features)
      for component in range(n_features):
          learner = ComponentwiseLeastSquares(component).fit(
              X, residuals, sample_weight
          )
          l_pred = learner.predict(X)
          error[component] = squared_norm(residuals - l_pred)
          base_learners.append(learner)
  
      # TODO: could use bottleneck.nanargmin for speed
      best_component = np.nanargmin(error)
      best_learner = base_learners[best_component]
      return best_learner
  
imports: import numbers
  import numpy
  from scipy.sparse import csc_matrix, csr_matrix, issparse
  from sklearn.base import BaseEstimator
  from sklearn.ensemble._base import BaseEnsemble
  from sklearn.ensemble._gb import BaseGradientBoosting, VerboseReporter
  from sklearn.ensemble._gradient_boosting import _random_sample_mask
  from sklearn.model_selection import train_test_split
  from sklearn.tree import DecisionTreeRegressor
  from sklearn.tree._tree import DTYPE
  from sklearn.utils import check_consistent_length, check_random_state, column_or_1d
  from sklearn.utils._param_validation import Interval, StrOptions
  from sklearn.utils.extmath import squared_norm
  from sklearn.utils.validation import check_is_fitted
  from ..base import SurvivalAnalysisMixin
  from ..linear_model.coxph import BreslowEstimator
  from ..util import check_array_survival
  from .survival_loss import LOSS_FUNCTIONS, CensoredSquaredLoss, CoxPH, IPCWLeastSquaresError
label_desc: Use image node_id 2 for calling a global function with example usage: _fit_stage_componentwise(X, residuals, sample_weight) and returns: best_learner