code: def test_select_top_trials(
      direction: StudyDirection,
      top_trials_ratio: float,
      min_n_trials: int,
      n_trials_expected: int,
  ) -> None:
      values = [1, 0, 0, 2, 1]
      trials_before = [create_trial(value=v) for v in values]
  
      values_in_order = sorted(
          values, reverse=(direction == StudyDirection.MAXIMIZE)
      )
  
      p = _preprocessing.SelectTopTrials(
          top_trials_ratio=top_trials_ratio,
          min_n_trials=min_n_trials,
      )
      trials_after = p.apply(trials_before, direction)
  
      assert len(trials_after) == n_trials_expected
      assert (
          _get_trial_values(trials_after)
          == values_in_order[:n_trials_expected]
      )
  
file_path: optuna/tests/terminator_tests/improvement_tests/test_preprocessing.py
imports: from __future__ import annotations
  from unittest import mock
  import numpy
  import pytest
  from optuna.distributions import CategoricalDistribution
  from optuna.distributions import FloatDistribution
  from optuna.distributions import IntDistribution
  from optuna.study._study_direction import StudyDirection
  from optuna.terminator.improvement import _preprocessing
  from optuna.trial import create_trial
  from optuna.trial import FrozenTrial
label_desc: Use image node_id 5 for calling a global function with example usage: test_select_top_trials(direction, top_trials_ratio, min_n_trials, n_trials_expected) without return types