class_docstr: Base class for histogram-based gradient boosting estimators.
class_docstr_tok: ["Base","class","for","histogram-based","gradient","boosting","estimators","."]
docstr: Check and validation for interaction constraints.
docstr_tok: ["Check","and","validation","for","interaction","constraints","."]
code: def _check_interaction_cst(self, n_features):
      """Check and validation for interaction constraints."""
      if self.interaction_cst is None:
          return None
  
      if self.interaction_cst == "no_interactions":
          interaction_cst = [[i] for i in range(n_features)]
      elif self.interaction_cst == "pairwise":
          interaction_cst = itertools.combinations(range(n_features), 2)
      else:
          interaction_cst = self.interaction_cst
  
      try:
          constraints = [set(group) for group in interaction_cst]
      except TypeError:
          raise ValueError(
              "Interaction constraints must be a sequence of tuples or lists, got:"
              f" {self.interaction_cst!r}."
          )
  
      for group in constraints:
          for x in group:
              if not (isinstance(x, Integral) and 0 <= x < n_features):
                  raise ValueError(
                      "Interaction constraints must consist of integer indices in"
                      f" [0, n_features - 1] = [0, {n_features - 1}], specifying the"
                      " position of features, got invalid indices:"
                      f" {group!r}"
                  )
  
      # Add all not listed features as own group by default.
      rest = set(range(n_features)) - set().union(*constraints)
      if len(rest) > 0:
          constraints.append(rest)
  
      return constraints
  
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 5 for calling the BaseHistGradientBoosting obj's underlying member method code with example usage: obj._check_interaction_cst(n_features) and returns: constraints, None