code: def test_predictor_from_grower():
      # Build a tree on the toy 3-leaf dataset to extract the predictor.
      n_bins = 256
      X_binned, all_gradients, all_hessians = _make_training_data(
          n_bins=n_bins
      )
      grower = TreeGrower(
          X_binned,
          all_gradients,
          all_hessians,
          n_bins=n_bins,
          shrinkage=1.0,
          max_leaf_nodes=3,
          min_samples_leaf=5,
      )
      grower.grow()
      assert grower.n_nodes == 5  # (2 decision nodes + 3 leaves)
  
      # Check that the node structure can be converted into a predictor
      # object to perform predictions at scale
      # We pass undefined binning_thresholds because we won't use predict anyway
      predictor = grower.make_predictor(
          binning_thresholds=np.zeros((X_binned.shape[1], n_bins))
      )
      assert predictor.nodes.shape[0] == 5
      assert predictor.nodes["is_leaf"].sum() == 3
  
      # Probe some predictions for each leaf of the tree
      # each group of 3 samples corresponds to a condition in _make_training_data
      input_data = np.array(
          [
              [0, 0],
              [42, 99],
              [128, 254],
              [129, 0],
              [129, 85],
              [254, 85],
              [129, 86],
              [129, 254],
              [242, 100],
          ],
          dtype=np.uint8,
      )
      missing_values_bin_idx = n_bins - 1
      predictions = predictor.predict_binned(
          input_data, missing_values_bin_idx, n_threads
      )
      expected_targets = [1, 1, 1, 1, 1, 1, -1, -1, -1]
      assert np.allclose(predictions, expected_targets)
  
      # Check that training set can be recovered exactly:
      predictions = predictor.predict_binned(
          X_binned, missing_values_bin_idx, n_threads
      )
      assert np.allclose(predictions, -all_gradients)
  
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from pytest import approx
  from sklearn.ensemble._hist_gradient_boosting.binning import _BinMapper
  from sklearn.ensemble._hist_gradient_boosting.common import G_H_DTYPE, X_BINNED_DTYPE, X_BITSET_INNER_DTYPE, X_DTYPE, Y_DTYPE
  from sklearn.ensemble._hist_gradient_boosting.grower import TreeGrower
  from sklearn.preprocessing import OneHotEncoder
  from sklearn.utils._openmp_helpers import _openmp_effective_n_threads
label_desc: Use image node_id 4 for calling a global function with example usage: test_predictor_from_grower() without return types