code: def test_candidates_nbest_float_single_objective(
      builder: EnsembleBuilder,
      make_run: Callable[..., Run],
      nbest: float,
  ) -> None:
      """
      Expects
      -------
      * Should select nbest percentage of candidates
      * They should be ordered by loss
      """
      # Make sure it's single objective being tested
      assert len(builder.metrics) == 1
      metric = builder.metrics[0]
  
      n = 10
      expected = int(bound(nbest * n, bounds=(1, n)))
  
      dummy = make_run(dummy=True, losses={metric.name: 50_000})
      runs = [
          make_run(id=i, losses={metric.name: i})
          for i in range(2, n + 2)
      ]
  
      candidates, discarded = builder.candidate_selection(
          runs, dummy, nbest=nbest
      )
  
      assert len(candidates) == expected
  
      if len(candidates) > 1:
          for a, b in pairs(candidates):
              assert a.losses[metric.name] <= b.losses[metric.name]
  
      # Make sure all discarded are worse than the worst candidate
      if any(discarded):
          worst_candidate_loss = candidates[-1].losses[metric.name]
  
          for d in discarded:
              assert worst_candidate_loss <= d.losses[metric.name]
  
imports: from __future__ import annotations
  from typing import Callable
  import random
  import time
  from pathlib import Path
  import numpy
  from autosklearn.automl_common.common.utils.backend import Backend
  from autosklearn.ensemble_building import EnsembleBuilder, Run
  from autosklearn.metrics import Scorer, accuracy, make_scorer
  from autosklearn.util.functional import bound, pairs
  import pytest
  from pytest_cases import fixture, parametrize
  from unittest.mock import Mock, patch
  from test.conftest import DEFAULT_SEED
  from test.fixtures.metrics import acc_with_X_data
label_desc: Use image node_id 14 for calling a global function with example usage: test_candidates_nbest_float_single_objective(builder, make_run, nbest) without return types