class_docstr: Tree grower class used to build a tree.
  
  The tree is fitted to predict the values of a Newton-Raphson step. The
  splits are considered in a best-first fashion, and the quality of a
  split is defined in splitting._split_gain.
  
  Parameters
  ----------
  X_binned : ndarray of shape (n_samples, n_features), dtype=np.uint8
      The binned input samples. Must be Fortran-aligned.
  gradients : ndarray of shape (n_samples,)
      The gradients of each training sample. Those are the gradients of the
      loss w.r.t the predictions, evaluated at iteration ``i - 1``.
  hessians : ndarray of shape (n_samples,)
      The hessians of each training sample. Those are the hessians of the
      loss w.r.t the predictions, evaluated at iteration ``i - 1``.
  max_leaf_nodes : int, default=None
      The maximum number of leaves for each tree. If None, there is no
      maximum limit.
  max_depth : int, default=None
      The maximum depth of each tree. The depth of a tree is the number of
      edges to go from the root to the deepest leaf.
      Depth isn't constrained by default.
  min_samples_leaf : int, default=20
      The minimum number of samples per leaf.
  min_gain_to_split : float, default=0.
      The minimum gain needed to split a node. Splits with lower gain will
      be ignored.
  min_hessian_to_split : float, default=1e-3
      The minimum sum of hessians needed in each node. Splits that result in
      at least one child having a sum of hessians less than
      ``min_hessian_to_split`` are discarded.
  n_bins : int, default=256
      The total number of bins, including the bin for missing values. Used
      to define the shape of the histograms.
  n_bins_non_missing : ndarray, dtype=np.uint32, default=None
      For each feature, gives the number of bins actually used for
      non-missing values. For features with a lot of unique values, this
      is equal to ``n_bins - 1``. If it's an int, all features are
      considered to have the same number of bins. If None, all features
      are considered to have ``n_bins - 1`` bins.
  has_missing_values : bool or ndarray, dtype=bool, default=False
      Whether each feature contains missing values (in the training data).
      If it's a bool, the same value is used for all features.
  is_categorical : ndarray of bool of shape (n_features,), default=None
      Indicates categorical features.
  monotonic_cst : array-like of int of shape (n_features,), dtype=int, default=None
      Indicates the monotonic constraint to enforce on each feature.
        - 1: monotonic increase
        - 0: no constraint
        - -1: monotonic decrease
  
      Read more in the :ref:`User Guide <monotonic_cst_gbdt>`.
  interaction_cst : list of sets of integers, default=None
      List of interaction constraints.
  l2_regularization : float, default=0.
      The L2 regularization parameter.
  feature_fraction_per_split : float, default=1
      Proportion of randomly chosen features in each and every node split.
      This is a form of regularization, smaller values make the trees weaker
      learners and might prevent overfitting.
  rng : Generator
      Numpy random Generator used for feature subsampling.
  shrinkage : float, default=1.
      The shrinkage parameter to apply to the leaves values, also known as
      learning rate.
  n_threads : int, default=None
      Number of OpenMP threads to use. `_openmp_effective_n_threads` is called
      to determine the effective number of threads use, which takes cgroups CPU
      quotes into account. See the docstring of `_openmp_effective_n_threads`
      for details.
  
  Attributes
  ----------
  histogram_builder : HistogramBuilder
  splitter : Splitter
  root : TreeNode
  finalized_leaves : list of TreeNode
  splittable_nodes : list of TreeNode
  missing_values_bin_idx : int
      Equals n_bins - 1
  n_categorical_splits : int
  n_features : int
  n_nodes : int
  total_find_split_time : float
      Time spent finding the best splits
  total_compute_hist_time : float
      Time spent computing histograms
  total_apply_split_time : float
      Time spent splitting nodes
  with_monotonic_cst : bool
      Whether there are monotonic constraints that apply. False iff monotonic_cst is
      None.
class_docstr_tok: ["Tree","grower","class","used","to","build","a","tree",".","The","tree","is","fitted","to","predict","the","values","of","a","Newton-Raphson","step",".","The","splits","are","considered","in","a","best-first","fashion",",","and","the","quality","of","a","split","is","defined","in","splitting._split_gain",".","Parameters","--","--","--","--","--","X_binned",":","ndarray","of","shape","(","n_samples",",","n_features",")",",","dtype=np.uint8","The","binned","input","samples",".","Must","be","Fortran-aligned",".","gradients",":","ndarray","of","shape","(","n_samples",",",")","The","gradients","of","each","training","sample",".","Those","are","the","gradients","of","the","loss","w.r.t","the","predictions",",","evaluated","at","iteration","``","i","-","1","``",".","hessians",":","ndarray","of","shape","(","n_samples",",",")","The","hessians","of","each","training","sample",".","Those","are","the","hessians","of","the","loss","w.r.t","the","predictions",",","evaluated","at","iteration","``","i","-","1","``",".","max_leaf_nodes",":","int",",","default=None","The","maximum","number","of","leaves","for","each","tree",".","If","None",",","there","is","no","maximum","limit",".","max_depth",":","int",",","default=None","The","maximum","depth","of","each","tree",".","The","depth","of","a","tree","is","the","number","of","edges","to","go","from","the","root","to","the","deepest","leaf",".","Depth","is","n't","constrained","by","default",".","min_samples_leaf",":","int",",","default=20","The","minimum","number","of","samples","per","leaf",".","min_gain_to_split",":","float",",","default=0",".","The","minimum","gain","needed","to","split","a","node",".","Splits","with","lower","gain","will","be","ignored",".","min_hessian_to_split",":","float",",","default=1e-3","The","minimum","sum","of","hessians","needed","in","each","node",".","Splits","that","result","in","at","least","one","child","having","a","sum","of","hessians","less","than","``","min_hessian_to_split","``","are","discarded",".","n_bins",":","int",",","default=256","The","total","number","of","bins",",","including","the","bin","for","missing","values",".","Used","to","define","the","shape","of","the","histograms",".","n_bins_non_missing",":","ndarray",",","dtype=np.uint32",",","default=None","For","each","feature",",","gives","the","number","of","bins","actually","used","for","non-missing","values",".","For","features","with","a","lot","of","unique","values",",","this","is","equal","to","``","n_bins","-","1","``",".","If","it","'s","an","int",",","all","features","are","considered","to","have","the","same","number","of","bins",".","If","None",",","all","features","are","considered","to","have","``","n_bins","-","1","``","bins",".","has_missing_values",":","bool","or","ndarray",",","dtype=bool",",","default=False","Whether","each","feature","contains","missing","values","(","in","the","training","data",")",".","If","it","'s","a","bool",",","the","same","value","is","used","for","all","features",".","is_categorical",":","ndarray","of","bool","of","shape","(","n_features",",",")",",","default=None","Indicates","categorical","features",".","monotonic_cst",":","array-like","of","int","of","shape","(","n_features",",",")",",","dtype=int",",","default=None","Indicates","the","monotonic","constraint","to","enforce","on","each","feature",".","-","1",":","monotonic","increase","-","0",":","no","constraint","-","-1",":","monotonic","decrease","Read","more","in","the",":","ref",":","`","User","Guide","<","monotonic_cst_gbdt",">","`",".","interaction_cst",":","list","of","sets","of","integers",",","default=None","List","of","interaction","constraints",".","l2_regularization",":","float",",","default=0",".","The","L2","regularization","parameter",".","feature_fraction_per_split",":","float",",","default=1","Proportion","of","randomly","chosen","features","in","each","and","every","node","split",".","This","is","a","form","of","regularization",",","smaller","values","make","the","trees","weaker","learners","and","might","prevent","overfitting",".","rng",":","Generator","Numpy","random","Generator","used","for","feature","subsampling",".","shrinkage",":","float",",","default=1",".","The","shrinkage","parameter","to","apply","to","the","leaves","values",",","also","known","as","learning","rate",".","n_threads",":","int",",","default=None","Number","of","OpenMP","threads","to","use",".","`","_openmp_effective_n_threads","`","is","called","to","determine","the","effective","number","of","threads","use",",","which","takes","cgroups","CPU","quotes","into","account",".","See","the","docstring","of","`","_openmp_effective_n_threads","`","for","details",".","Attributes","--","--","--","--","--","histogram_builder",":","HistogramBuilder","splitter",":","Splitter","root",":","TreeNode","finalized_leaves",":","list","of","TreeNode","splittable_nodes",":","list","of","TreeNode","missing_values_bin_idx",":","int","Equals","n_bins","-","1","n_categorical_splits",":","int","n_features",":","int","n_nodes",":","int","total_find_split_time",":","float","Time","spent","finding","the","best","splits","total_compute_hist_time",":","float","Time","spent","computing","histograms","total_apply_split_time",":","float","Time","spent","splitting","nodes","with_monotonic_cst",":","bool","Whether","there","are","monotonic","constraints","that","apply",".","False","iff","monotonic_cst","is","None","."]
docstr: Compute features allowed by interactions to be inherited by child nodes.
  
  Example: Assume constraints [{0, 1}, {1, 2}].
     1      <- Both constraint groups could be applied from now on
    / \
   1   2    <- Left split still fulfills both constraint groups.
  / \ / \      Right split at feature 2 has only group {1, 2} from now on.
  
  LightGBM uses the same logic for overlapping groups. See
  https://github.com/microsoft/LightGBM/issues/4481 for details.
  
  Parameters:
  ----------
  node : TreeNode
      A node that might have children. Based on its feature_idx, the interaction
      constraints for possible child nodes are computed.
  
  Returns
  -------
  allowed_features : ndarray, dtype=uint32
      Indices of features allowed to split for children.
  interaction_cst_indices : list of ints
      Indices of the interaction sets that have to be applied on splits of
      child nodes. The fewer sets the stronger the constraint as fewer sets
      contain fewer features.
docstr_tok: ["Compute","features","allowed","by","interactions","to","be","inherited","by","child","nodes",".","Example",":","Assume","constraints","[","{","0",",","1","}",",","{","1",",","2","}","]",".","1","<","-","Both","constraint","groups","could","be","applied","from","now","on","\/","\\","1","2","<","-","Left","split","still","fulfills","both","constraint","groups",".","\/","\\","\/","\\","Right","split","at","feature","2","has","only","group","{","1",",","2","}","from","now","on",".","LightGBM","uses","the","same","logic","for","overlapping","groups",".","See","https",":","\/\/github.com\/microsoft\/LightGBM\/issues\/4481","for","details",".","Parameters",":","--","--","--","--","--","node",":","TreeNode","A","node","that","might","have","children",".","Based","on","its","feature_idx",",","the","interaction","constraints","for","possible","child","nodes","are","computed",".","Returns","--","--","--","-","allowed_features",":","ndarray",",","dtype=uint32","Indices","of","features","allowed","to","split","for","children",".","interaction_cst_indices",":","list","of","ints","Indices","of","the","interaction","sets","that","have","to","be","applied","on","splits","of","child","nodes",".","The","fewer","sets","the","stronger","the","constraint","as","fewer","sets","contain","fewer","features","."]
code: def _compute_interactions(self, node):
      r"""Compute features allowed by interactions to be inherited by child nodes.
  
          Example: Assume constraints [{0, 1}, {1, 2}].
             1      <- Both constraint groups could be applied from now on
            / \
           1   2    <- Left split still fulfills both constraint groups.
          / \ / \      Right split at feature 2 has only group {1, 2} from now on.
  
          LightGBM uses the same logic for overlapping groups. See
          https://github.com/microsoft/LightGBM/issues/4481 for details.
  
          Parameters:
          ----------
          node : TreeNode
              A node that might have children. Based on its feature_idx, the interaction
              constraints for possible child nodes are computed.
  
          Returns
          -------
          allowed_features : ndarray, dtype=uint32
              Indices of features allowed to split for children.
          interaction_cst_indices : list of ints
              Indices of the interaction sets that have to be applied on splits of
              child nodes. The fewer sets the stronger the constraint as fewer sets
              contain fewer features.
          """
      # Note:
      #  - Case of no interactions is already captured before function call.
      #  - This is for nodes that are already split and have a
      #    node.split_info.feature_idx.
      allowed_features = set()
      interaction_cst_indices = []
      for i in node.interaction_cst_indices:
          if node.split_info.feature_idx in self.interaction_cst[i]:
              interaction_cst_indices.append(i)
              allowed_features.update(self.interaction_cst[i])
      return (
          np.fromiter(
              allowed_features,
              dtype=np.uint32,
              count=len(allowed_features),
          ),
          interaction_cst_indices,
      )
  
imports: import numbers
  from heapq import heappop, heappush
  from timeit import default_timer
  import numpy
  from sklearn.utils._openmp_helpers import _openmp_effective_n_threads
  from ._bitset import set_raw_bitset_from_binned_bitset
  from .common import PREDICTOR_RECORD_DTYPE, X_BITSET_INNER_DTYPE, Y_DTYPE, MonotonicConstraint
  from .histogram import HistogramBuilder
  from .predictor import TreePredictor
  from .splitting import Splitter
  from .utils import sum_parallel
label_desc: Use image node_id 8 for calling the TreeGrower obj's underlying member method code with example usage: obj._compute_interactions(node) and returns: np,  interaction_cst_indices