code: def _get_time_index(
      X: pd.DataFrame,
  ) -> pd.PeriodIndex | pd.DatetimeIndex:
      """Get time index from single and multi-index dataframes."""
      if isinstance(X.index, pd.MultiIndex):
          time_index = X.index.get_level_values(-1)
      else:
          time_index = X.index
      return time_index
  
file_path: sktime/sktime/transformations/series/time_since.py
imports: from __future__ import annotations
  import datetime
  import warnings
  from string import digits
  import numpy
  import pandas
  from pandas.tseries.frequencies import get_period_alias
  from sktime.transformations.base import BaseTransformer
label_desc: Use image node_id 3 for calling a global function with example usage: _get_time_index(X) and returns: time_index