code: def test_get_best_intermediate_result_over_steps(
      direction_expected: Tuple[StudyDirection, float]
  ) -> None:
      direction, expected = direction_expected
  
      if direction == StudyDirection.MINIMIZE:
          study = optuna.study.create_study(direction="minimize")
      else:
          study = optuna.study.create_study(direction="maximize")
  
      # FrozenTrial.intermediate_values has no elements.
      trial_id_empty = study._storage.create_new_trial(study._study_id)
      trial_empty = study._storage.get_trial(trial_id_empty)
  
      with pytest.raises(ValueError):
          _percentile._get_best_intermediate_result_over_steps(
              trial_empty, direction
          )
  
      # Input value has no NaNs but float values.
      trial_id_float = study._storage.create_new_trial(study._study_id)
      trial_float = optuna.trial.Trial(study, trial_id_float)
      trial_float.report(0.1, step=0)
      trial_float.report(0.2, step=1)
      frozen_trial_float = study._storage.get_trial(trial_id_float)
      assert (
          expected
          == _percentile._get_best_intermediate_result_over_steps(
              frozen_trial_float, direction
          )
      )
  
      # Input value has a float value and a NaN.
      trial_id_float_nan = study._storage.create_new_trial(
          study._study_id
      )
      trial_float_nan = optuna.trial.Trial(study, trial_id_float_nan)
      trial_float_nan.report(0.3, step=0)
      trial_float_nan.report(float("nan"), step=1)
      frozen_trial_float_nan = study._storage.get_trial(
          trial_id_float_nan
      )
      assert (
          0.3
          == _percentile._get_best_intermediate_result_over_steps(
              frozen_trial_float_nan, direction
          )
      )
  
      # Input value has a NaN only.
      trial_id_nan = study._storage.create_new_trial(study._study_id)
      trial_nan = optuna.trial.Trial(study, trial_id_nan)
      trial_nan.report(float("nan"), step=0)
      frozen_trial_nan = study._storage.get_trial(trial_id_nan)
      with warnings.catch_warnings():
          warnings.simplefilter("ignore", category=RuntimeWarning)
          assert math.isnan(
              _percentile._get_best_intermediate_result_over_steps(
                  frozen_trial_nan, direction
              )
          )
  
file_path: optuna/tests/pruners_tests/test_percentile.py
imports: import math
  from typing import List
  from typing import Tuple
  import warnings
  import pytest
  import optuna
  from optuna.pruners import _percentile
  from optuna.study import Study
  from optuna.study import StudyDirection
  from optuna.trial import TrialState
label_desc: Use image node_id 8 for calling a global function with example usage: test_get_best_intermediate_result_over_steps(direction_expected) without return types