code: def check_time_index(
      index: Union[pd.Index, np.array],
      allow_empty: bool = False,
      enforce_index_type: bool = None,
      var_name: str = "input",
  ) -> pd.Index:
      """Check time index.
  
      Parameters
      ----------
      index : pd.Index or np.array
          Time index
      allow_empty : bool, optional (default=False)
          If False, empty `index` raises an error.
      enforce_index_type : type, optional (default=None)
          type of time index
      var_name : str, default = "input" - variable name printed in error messages
  
      Returns
      -------
      time_index : pd.Index
          Validated time index - a reference to the input index
      """
      if isinstance(index, np.ndarray):
          index = pd.Index(index)
  
      # We here check for type equality because isinstance does not
      # work reliably because index types inherit from each other.
      if not is_in_valid_index_types(index):
          raise NotImplementedError(
              f"{type(index)} is not supported for {var_name}, use "
              f"one of {VALID_INDEX_TYPES} instead."
          )
  
      if enforce_index_type and type(index) is not enforce_index_type:
          raise NotImplementedError(
              f"{type(index)} is not supported for {var_name}, use "
              f"type: {enforce_index_type} or integer pd.Index instead."
          )
  
      # Check time index is ordered in time
      if not index.is_monotonic_increasing:
          raise ValueError(
              f"The (time) index of {var_name} must be sorted monotonically increasing, "
              f"but found: {index}"
          )
  
      # Check that index is not empty
      if not allow_empty and len(index) < 1:
          raise ValueError(
              f"{var_name} must contain at least some values, but found none."
          )
  
      return index
  
file_path: sktime/sktime/utils/validation/series.py
imports: from typing import Union
  import numpy
  import pandas
label_desc: Use image node_id 8 for calling a global function with example usage: check_time_index(index, allow_empty, enforce_index_type, var_name) and returns: index