class_docstr: Check for overfit caused by using too many iterations in a gradient boosted model.
  
  The check runs a pre-defined number of steps, and in each step it limits the boosting model to use up to X
  estimators (number of estimators is monotonic increasing). It plots the given score calculated for each step for
  both the train dataset and the test dataset.
  
  Parameters
  ----------
  scorer : Union[Callable, str] , default: None
      Scorer used to verify the model, either function or sklearn scorer name.
  scorer_name : str , default: None
      Name to be displayed in the plot on y-axis. must be used together with 'scorer'
  num_steps : int , default: 20
      Number of splits of the model iterations to check.
  n_samples : int , default: 1_000_000
      number of samples to use for this check.
  random_state : int, default: 42
      random seed for all check internals.
docstr: Run check.
  
  Returns
  -------
  CheckResult
      The score value on the test dataset.
docstr_tok: ["Run","check",".","Returns","--","--","--","-","CheckResult","The","score","value","on","the","test","dataset","."]
code: def run_logic(self, context: Context) -> CheckResult:
      """Run check.
  
      Returns
      -------
      CheckResult
          The score value on the test dataset.
      """
      train_dataset = context.train.sample(
          self.n_samples, random_state=self.random_state
      )
      test_dataset = context.test.sample(
          self.n_samples, random_state=self.random_state
      )
      model = context.model
  
      # Get default scorer
      scorer = context.get_single_scorer(self.alternative_scorer)
  
      # Get number of estimators on model
      num_estimators = PartialBoostingModel.n_estimators(model)
      estimator_steps = _calculate_steps(self.num_steps, num_estimators)
  
      train_scores = []
      test_scores = []
      for step in estimator_steps:
          train_scores.append(
              _partial_score(scorer, train_dataset, model, step)
          )
          test_scores.append(
              _partial_score(scorer, test_dataset, model, step)
          )
  
      result = {"test": test_scores, "train": train_scores}
  
      if context.with_display:
          fig = go.Figure()
          fig.add_trace(
              go.Scatter(
                  x=estimator_steps,
                  y=np.array(train_scores),
                  mode="lines+markers",
                  name="Training score",
              )
          )
          fig.add_trace(
              go.Scatter(
                  x=estimator_steps,
                  y=np.array(test_scores),
                  mode="lines+markers",
                  name="Test score",
              )
          )
          fig.update_layout(
              title_text=f"{scorer.name} score compared to number of boosting iteration",
              height=500,
          )
          fig.update_xaxes(title="Number of boosting iterations")
          fig.update_yaxes(title=scorer.name)
  
          display_text = f"""<span>
                  The check limits the boosting model to using up to N estimators each time, and plotting the
                  {scorer.name} calculated for each subset of estimators for both the train dataset and the test dataset.
              </span>"""
          display = [display_text, fig]
      else:
          display = None
  
      return CheckResult(
          result, display=display, header="Boosting Overfit"
      )
  
imports: from copy import deepcopy
  from typing import TYPE_CHECKING, Callable, Tuple, Union
  import numpy
  import plotly.graph_objects
  from sklearn.pipeline import Pipeline
  from deepchecks.core import CheckResult, ConditionCategory, ConditionResult
  from deepchecks.core.errors import DeepchecksValueError, ModelValidationError
  from deepchecks.tabular import Context, TrainTestCheck
  from deepchecks.utils.docref import doclink
  from deepchecks.utils.model import get_model_of_pipeline
  from deepchecks.utils.strings import format_percent
label_desc: Use image node_id 2 for calling the BoostingOverfit obj's underlying member method code with example usage: obj.run_logic(context) and returns: CheckResult