code: def test_temporal_train_test_split_hierarchical():
      """Test correctness of temporal_train_test_split for hierarchical data.
  
      Failure case is bug #5107.
      """
      from sktime.utils._testing.hierarchical import _make_hierarchical
  
      y = _make_hierarchical()
      y_train, y_test = temporal_train_test_split(y, test_size=0.2)
  
      # y has 12 time indices per series, the same indices for all series
      # so 9 indices should be in train and 3 in test
      # the failure case in 5107 would ignore the hierarchical structure and just
      # put the last 20 indices of the hierarchical data frame in test
      assert len(y_train.index.get_level_values(-1).unique()) == 9
      assert len(y_test.index.get_level_values(-1).unique()) == 3
  
file_path: sktime/sktime/split/tests/test_temporaltraintest.py
imports: import numpy
  import pandas
  import pytest
  from sktime.datasets import load_airline
  from sktime.datatypes._utilities import get_cutoff
  from sktime.forecasting.tests._config import TEST_OOS_FHS, VALID_INDEX_FH_COMBINATIONS
  from sktime.split import temporal_train_test_split
  from sktime.utils._testing.forecasting import _make_fh
  from sktime.utils._testing.series import _make_series
label_desc: Use image node_id 5 for calling a global function with example usage: test_temporal_train_test_split_hierarchical() without return types