code: def test_aggregator_flatten():
      """Tests Aggregator flattening single levels.
  
      This tests that the flatten_single_levels argument works as expected for a fixed
      example of a complicated hierarchy.
      """
      agg = Aggregator(flatten_single_levels=False)
      agg_flat = Aggregator(flatten_single_levels=True)
  
      X = _bottom_hier_datagen(
          no_bottom_nodes=10,
          no_levels=4,
          random_seed=111,
      )
      # aggregate without flattening
      X_agg = agg.fit_transform(X)
      # aggregate with flattening
      X_agg_flat = agg_flat.fit_transform(X)
  
      msg = (
          "Aggregator without flattening should have 21 unique levels, "
          "with the time index removed, for random_seed=111."
      )
      assert len(X_agg.droplevel(-1).index.unique()) == 21, msg
  
      msg = (
          "Aggregator with flattening should have 17 unique levels, "
          "with the time index removed, for random_seed=111."
      )
      assert len(X_agg_flat.droplevel(-1).index.unique()) == 17, msg
  
imports: import pytest
  from sktime.tests.test_switch import run_test_for_class
  from sktime.transformations.hierarchical.aggregate import Aggregator
  from sktime.utils._testing.hierarchical import _bottom_hier_datagen
label_desc: Use image node_id 2 for calling a global function with example usage: test_aggregator_flatten() without return types