code: def test_candidates_filters_runs_with_no_loss(
      builder: EnsembleBuilder, make_run: Callable[..., Run]
  ) -> None:
      """
      Expects
      -------
      * Should filter out runs with no loss
      """
      metrics = builder.metrics
  
      bad_runs = [make_run(losses=None) for _ in range(5)]
      dummy_run = make_run(
          dummy=True, losses={m.name: 2 for m in metrics}
      )
      good_run = make_run(losses={m.name: 1 for m in metrics})
  
      runs = bad_runs + [good_run]
  
      candidates, discarded = builder.candidate_selection(
          runs, dummy_run
      )
  
      assert len(candidates) == 1
      assert len(discarded) == len(bad_runs)
  
      # Only candidate should be the one with a loss of 1
      assert candidates[0].losses == {m.name: 1 for m in metrics}
  
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 9 for calling a global function with example usage: test_candidates_filters_runs_with_no_loss(builder, make_run) without return types