code: def test_nsga2_ranking_2() -> None:
      candidates, expected_frontiers = get_nsga2_test_case_data()
      n_selected = (
          len(expected_frontiers[0]) + len(expected_frontiers[1]) - 1
      )
      rank_result = nsga2.rank(candidates, n_selected)
  
      assert len(rank_result) == n_selected
      # Check the first frontier
      max_rank_frontier1 = 0
      for c in expected_frontiers[0]:
          assert rank_result[c.uid][2] == float("inf")
          max_rank_frontier1 = max(
              max_rank_frontier1, rank_result[c.uid][0]
          )
  
      # Check the second frontier
      n_cand_in_frontier2 = 0
      for c in expected_frontiers[1]:
          if c.uid in rank_result:
              n_cand_in_frontier2 += 1
              assert rank_result[c.uid][0] > max_rank_frontier1
      assert n_cand_in_frontier2 == len(expected_frontiers[1]) - 1
  
file_path: nevergrad/nevergrad/optimization/multiobjective/test_nsga2.py
imports: import random
  import numpy
  import nevergrad
  import nevergrad.common.typing
  from nevergrad.parametrization import parameter
  from .None import nsga2
label_desc: Use image node_id 5 for calling a global function with example usage: test_nsga2_ranking_2() without return types