code: def test_collapse_levels(space, n_levels):
      N = 20
      transformer = Transformer(space, n_levels)
      trials = get_n_completed_trials(space, N)
  
      olh_perf_table = transformer.generate_olh_perf_table(trials)
      oa_table = transformer._collapse_levels(olh_perf_table, n_levels)
      assert oa_table.to_numpy()[:, :-1].min() == 1
      assert oa_table.to_numpy()[:, :-1].max() == n_levels
      assert (oa_table["objective"] == range(N)).all()
  
file_path: orion/tests/unittests/algo/mofa/test_analysis.py
imports: import itertools
  import numpy
  import pandas
  import pytest
  from orion.algo.mofa.mofa import MOFA, get_factorial_importance_analysis, get_factorial_performance_analysis, select_new_region_of_interest
  from orion.algo.mofa.transformer import Transformer
  from orion.core.io.space_builder import SpaceBuilder
  from orion.core.worker.transformer import build_required_space
label_desc: Use image node_id 4 for calling a global function with example usage: test_collapse_levels(space, n_levels) without return types