code: def test_get_percentile_intermediate_result_over_trials() -> None:
      def setup_study(
          trial_num: int, _intermediate_values: List[List[float]]
      ) -> Study:
          _study = optuna.study.create_study(direction="minimize")
          trial_ids = [
              _study._storage.create_new_trial(_study._study_id)
              for _ in range(trial_num)
          ]
  
          for step, values in enumerate(_intermediate_values):
              # Study does not have any complete trials.
              with pytest.raises(ValueError):
                  completed_trials = _study.get_trials(
                      deepcopy=False, states=(TrialState.COMPLETE,)
                  )
                  _direction = _study.direction
                  _percentile._get_percentile_intermediate_result_over_trials(
                      completed_trials, _direction, step, 25, 1
                  )
  
              for i in range(trial_num):
                  trial_id = trial_ids[i]
                  value = values[i]
                  _study._storage.set_trial_intermediate_value(
                      trial_id, step, value
                  )
  
          # Set trial states complete because this method ignores incomplete trials.
          for trial_id in trial_ids:
              _study._storage.set_trial_state_values(
                  trial_id, state=TrialState.COMPLETE
              )
  
          return _study
  
      # Input value has no NaNs but float values (step=0).
      intermediate_values = [
          [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
      ]
      study = setup_study(9, intermediate_values)
      all_trials = study.get_trials()
      direction = study.direction
      assert (
          0.3
          == _percentile._get_percentile_intermediate_result_over_trials(
              all_trials, direction, 0, 25.0, 1
          )
      )
  
      # Input value has a float value and NaNs (step=1).
      intermediate_values.append(
          [
              0.1,
              0.2,
              0.3,
              0.4,
              0.5,
              float("nan"),
              float("nan"),
              float("nan"),
              float("nan"),
          ]
      )
      study = setup_study(9, intermediate_values)
      all_trials = study.get_trials()
      direction = study.direction
      assert (
          0.2
          == _percentile._get_percentile_intermediate_result_over_trials(
              all_trials, direction, 1, 25.0, 1
          )
      )
  
      # Input value has NaNs only (step=2).
      intermediate_values.append(
          [
              float("nan"),
              float("nan"),
              float("nan"),
              float("nan"),
              float("nan"),
              float("nan"),
              float("nan"),
              float("nan"),
              float("nan"),
          ]
      )
      study = setup_study(9, intermediate_values)
      all_trials = study.get_trials()
      direction = study.direction
      with warnings.catch_warnings():
          warnings.simplefilter("ignore", category=RuntimeWarning)
          assert math.isnan(
              _percentile._get_percentile_intermediate_result_over_trials(
                  all_trials, direction, 2, 75, 1
              )
          )
  
          # n_min_trials = 2.
          assert math.isnan(
              _percentile._get_percentile_intermediate_result_over_trials(
                  all_trials, direction, 2, 75, 2
              )
          )
  
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 9 for calling a global function with example usage: test_get_percentile_intermediate_result_over_trials() and returns: _study