code: def _update_leaves_values(
      loss, grower, y_true, raw_prediction, sample_weight
  ):
      """Update the leaf values to be predicted by the tree.
  
      Update equals:
          loss.fit_intercept_only(y_true - raw_prediction)
  
      This is only applied if loss.need_update_leaves_values is True.
      Note: It only works, if the loss is a function of the residual, as is the
      case for AbsoluteError and PinballLoss. Otherwise, one would need to get
      the minimum of loss(y_true, raw_prediction + x) in x. A few examples:
        - AbsoluteError: median(y_true - raw_prediction).
        - PinballLoss: quantile(y_true - raw_prediction).
      See also notes about need_update_leaves_values in BaseLoss.
      """
      # TODO: Ideally this should be computed in parallel over the leaves using something
      # similar to _update_raw_predictions(), but this requires a cython version of
      # median().
      for leaf in grower.finalized_leaves:
          indices = leaf.sample_indices
          if sample_weight is None:
              sw = None
          else:
              sw = sample_weight[indices]
          update = loss.fit_intercept_only(
              y_true=y_true[indices] - raw_prediction[indices],
              sample_weight=sw,
          )
          leaf.value = grower.shrinkage * update
  
imports: import itertools
  from abc import ABC, abstractmethod
  from functools import partial
  from numbers import Integral, Real
  from timeit import default_timer
  import numpy
  from ..._loss.loss import _LOSSES, BaseLoss, HalfBinomialLoss, HalfGammaLoss, HalfMultinomialLoss, HalfPoissonLoss, PinballLoss
  from ...base import BaseEstimator, ClassifierMixin, RegressorMixin, _fit_context, is_classifier
  from ...metrics import check_scoring
  from ...model_selection import train_test_split
  from ...preprocessing import LabelEncoder
  from ...utils import check_random_state, compute_sample_weight, resample
  from ...utils._openmp_helpers import _openmp_effective_n_threads
  from ...utils._param_validation import Interval, RealNotInt, StrOptions
  from ...utils.multiclass import check_classification_targets
  from ...utils.validation import _check_monotonic_cst, _check_sample_weight, check_consistent_length, check_is_fitted
  from ._gradient_boosting import _update_raw_predictions
  from .binning import _BinMapper
  from .common import G_H_DTYPE, X_DTYPE, Y_DTYPE
  from .grower import TreeGrower
label_desc: Use image node_id 1 for calling a global function with example usage: _update_leaves_values(loss, grower, y_true, raw_prediction, sample_weight) without return types