code: def test_best_value_stagnation_evaluate() -> None:
      evaluator = BestValueStagnationEvaluator(max_stagnation_trials=1)
      # A case of monotonical improvement (best step is the latest element).
      trials = [create_trial(value=value) for value in [0, 1, 2]]
      assert (
          evaluator.evaluate(
              trials=trials, study_direction=StudyDirection.MAXIMIZE
          )
          == 1
      )
      trials = [create_trial(value=value) for value in [2, 1, 0]]
      assert (
          evaluator.evaluate(
              trials=trials, study_direction=StudyDirection.MINIMIZE
          )
          == 1
      )
      # A case of jagged improvement (best step is the second element).
      trials = [create_trial(value=value) for value in [0, 1, 0]]
      assert (
          evaluator.evaluate(
              trials=trials, study_direction=StudyDirection.MAXIMIZE
          )
          == 0
      )
      trials = [create_trial(value=value) for value in [1, 0, 1]]
      assert (
          evaluator.evaluate(
              trials=trials, study_direction=StudyDirection.MINIMIZE
          )
          == 0
      )
      # A case of flat improvement (best step is the first element).
      trials = [create_trial(value=value) for value in [0, 0, 0]]
      assert (
          evaluator.evaluate(
              trials=trials, study_direction=StudyDirection.MAXIMIZE
          )
          == -1
      )
      assert (
          evaluator.evaluate(
              trials=trials, study_direction=StudyDirection.MINIMIZE
          )
          == -1
      )
  
imports: from typing import List
  from typing import Tuple
  from unittest import mock
  import numpy
  import pytest
  from optuna.distributions import FloatDistribution
  from optuna.study import StudyDirection
  from optuna.terminator import BestValueStagnationEvaluator
  from optuna.terminator import RegretBoundEvaluator
  from optuna.terminator.improvement._preprocessing import NullPreprocessing
  from optuna.terminator.improvement.evaluator import BaseImprovementEvaluator
  from optuna.terminator.improvement.gp.base import _get_beta
  from optuna.terminator.improvement.gp.base import BaseGaussianProcess
  from optuna.trial import create_trial
  from optuna.trial import FrozenTrial
label_desc: Use image node_id 3 for calling a global function with example usage: test_best_value_stagnation_evaluate() without return types