code: def test_random_search(
      max_resources, n_candidates, expected_n_candidates
  ):
      # Test random search and make sure the number of generated candidates is
      # as expected
  
      n_samples = 1024
      X, y = make_classification(n_samples=n_samples, random_state=0)
      param_grid = {"a": norm, "b": norm}
      base_estimator = FastClassifier()
      sh = HalvingRandomSearchCV(
          base_estimator,
          param_grid,
          n_candidates=n_candidates,
          cv=2,
          max_resources=max_resources,
          factor=2,
          min_resources=4,
      )
      sh.fit(X, y)
      assert sh.n_candidates_[0] == expected_n_candidates
      if n_candidates == "exhaust":
          # Make sure 'exhaust' makes the last iteration use as much resources as
          # we can
          assert sh.n_resources_[-1] == max_resources
  
imports: from math import ceil
  import numpy
  import pytest
  from scipy.stats import expon, norm, randint
  from sklearn.datasets import make_classification
  from sklearn.dummy import DummyClassifier
  from sklearn.experimental import enable_halving_search_cv
  from sklearn.model_selection import GroupKFold, GroupShuffleSplit, HalvingGridSearchCV, HalvingRandomSearchCV, KFold, LeaveOneGroupOut, LeavePGroupsOut, ShuffleSplit, StratifiedKFold, StratifiedShuffleSplit
  from sklearn.model_selection._search_successive_halving import _SubsampleMetaSplitter, _top_k
  from sklearn.model_selection.tests.test_search import check_cv_results_array_types, check_cv_results_keys
  from sklearn.svm import SVC, LinearSVC
label_desc: Use image node_id 6 for calling a global function with example usage: test_random_search(max_resources, n_candidates, expected_n_candidates) without return types