code: def test_aggregator_fit_transform_index(flatten_single_levels):
      """Tests fit_transform of aggregator function.
  
      This test asserts that the output of Aggregator using fit_transform() with a named
      multiindex is equal to an unnamed one. It also tests that Aggregator does not change
      the names of the input index in both cases.
      """
      agg = Aggregator(flatten_single_levels=flatten_single_levels)
  
      X = _bottom_hier_datagen(
          no_bottom_nodes=3,
          no_levels=1,
      )
      # named indexes
      X_agg = agg.fit_transform(X)
      msg = "Aggregator returns wrong index names."
      assert X_agg.index.names == X.index.names, msg
  
      # unnamed indexes
      X.index.rename([None] * X.index.nlevels, inplace=True)
      X_agg_unnamed = agg.fit_transform(X)
      assert X_agg_unnamed.index.names == X.index.names, msg
  
      msg = "Aggregator returns different output for named and unnamed indexes."
      assert X_agg.equals(X_agg_unnamed), 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 1 for calling a global function with example usage: test_aggregator_fit_transform_index(flatten_single_levels) without return types