class_docstr: Evaluates the stagnation period of the best value in an optimization process.
  
  This class is initialized with a maximum stagnation period (`max_stagnation_trials`)
  and is designed to evaluate the remaining trials before reaching this maximum period
  of allowed stagnation. If this remaining trials reach zero, the trial terminates.
  Therefore, the default error evaluator is instantiated by StaticErrorEvaluator(const=0).
  
  Args:
      max_stagnation_trials:
          The maximum number of trials allowed for stagnation.
class_docstr_tok: ["Evaluates","the","stagnation","period","of","the","best","value","in","an","optimization","process",".","This","class","is","initialized","with","a","maximum","stagnation","period","(","`","max_stagnation_trials","`",")","and","is","designed","to","evaluate","the","remaining","trials","before","reaching","this","maximum","period","of","allowed","stagnation",".","If","this","remaining","trials","reach","zero",",","the","trial","terminates",".","Therefore",",","the","default","error","evaluator","is","instantiated","by","StaticErrorEvaluator","(","const=0",")",".","Args",":","max_stagnation_trials",":","The","maximum","number","of","trials","allowed","for","stagnation","."]
code: def evaluate(
      self,
      trials: List[FrozenTrial],
      study_direction: StudyDirection,
  ) -> float:
      self._validate_input(trials)
      is_maximize_direction = (
          True
          if (study_direction == StudyDirection.MAXIMIZE)
          else False
      )
      trials = [t for t in trials if t.state == TrialState.COMPLETE]
      current_step = len(trials) - 1
  
      best_step = 0
      for i, trial in enumerate(trials):
          best_value = trials[best_step].value
          current_value = trial.value
          assert best_value is not None
          assert current_value is not None
          if is_maximize_direction and (best_value < current_value):
              best_step = i
          elif (not is_maximize_direction) and (
              best_value > current_value
          ):
              best_step = i
  
      return self._max_stagnation_trials - (current_step - best_step)
  
imports: import abc
  from typing import Dict
  from typing import List
  from typing import Optional
  from optuna._experimental import experimental_class
  from optuna.distributions import BaseDistribution
  from optuna.search_space import intersection_search_space
  from optuna.study import StudyDirection
  from optuna.terminator.improvement._preprocessing import AddRandomInputs
  from optuna.terminator.improvement._preprocessing import BasePreprocessing
  from optuna.terminator.improvement._preprocessing import OneToHot
  from optuna.terminator.improvement._preprocessing import PreprocessingPipeline
  from optuna.terminator.improvement._preprocessing import SelectTopTrials
  from optuna.terminator.improvement._preprocessing import ToMinimize
  from optuna.terminator.improvement._preprocessing import UnscaleLog
  from optuna.terminator.improvement.gp.base import _min_lcb
  from optuna.terminator.improvement.gp.base import _min_ucb
  from optuna.terminator.improvement.gp.base import BaseGaussianProcess
  from optuna.terminator.improvement.gp.botorch import _BoTorchGaussianProcess
  from optuna.trial import FrozenTrial
  from optuna.trial import TrialState
label_desc: Use image node_id 2 for calling the BestValueStagnationEvaluator obj's underlying member method code with example usage: obj.evaluate(trials, study_direction) and returns: unknown