code: def assert_leaves_values_monotonic(predictor, monotonic_cst):
      # make sure leaves values (from left to right) are either all increasing
      # or all decreasing (or neither) depending on the monotonic constraint.
      nodes = predictor.nodes
  
      def get_leaves_values():
          """get leaves values from left to right"""
          values = []
  
          def depth_first_collect_leaf_values(node_idx):
              node = nodes[node_idx]
              if node["is_leaf"]:
                  values.append(node["value"])
                  return
              depth_first_collect_leaf_values(node["left"])
              depth_first_collect_leaf_values(node["right"])
  
          depth_first_collect_leaf_values(0)  # start at root (0)
          return values
  
      values = get_leaves_values()
  
      if monotonic_cst == MonotonicConstraint.NO_CST:
          # some increasing, some decreasing
          assert not is_increasing(values) and not is_decreasing(values)
      elif monotonic_cst == MonotonicConstraint.POS:
          # all increasing
          assert is_increasing(values)
      else:  # NEG
          # all decreasing
          assert is_decreasing(values)
  
file_path: scikit-learn/sklearn/ensemble/_hist_gradient_boosting/tests/test_monotonic_contraints.py
imports: import re
  import numpy
  import pytest
  from sklearn.ensemble import HistGradientBoostingClassifier, HistGradientBoostingRegressor
  from sklearn.ensemble._hist_gradient_boosting.common import G_H_DTYPE, X_BINNED_DTYPE, MonotonicConstraint
  from sklearn.ensemble._hist_gradient_boosting.grower import TreeGrower
  from sklearn.ensemble._hist_gradient_boosting.histogram import HistogramBuilder
  from sklearn.ensemble._hist_gradient_boosting.splitting import Splitter, compute_node_value
  from sklearn.utils._openmp_helpers import _openmp_effective_n_threads
  from sklearn.utils._testing import _convert_container
label_desc: Use image node_id 3 for calling a global function with example usage: assert_leaves_values_monotonic(predictor, monotonic_cst) and returns: values