code: def _index_equally_spaced(index):
      """Check whether pandas.index is equally spaced.
  
      Parameters
      ----------
      index: pandas.Index. Must be one of:
          pd.Int64Index, pd.RangeIndex, pd.PeriodIndex, pd.DatetimeIndex
  
      Returns
      -------
      equally_spaced: bool - whether index is equally spaced
      """
      if not is_in_valid_index_types(index):
          raise TypeError(
              f"index must be one of {VALID_INDEX_TYPES} or integer index"
          )
  
      # empty, single and two-element indices are equally spaced
      if len(index) < 3:
          return True
  
      # RangeIndex is always equally spaced
      if isinstance(index, pd.RangeIndex):
          return True
  
      if isinstance(index, pd.PeriodIndex):
          return index.is_full
  
      # we now treat a necessary condition for being equally spaced:
      # the first two spaces are equal. From now on, we know this.
      if index[1] - index[0] != index[2] - index[1]:
          return False
  
      # another necessary condition for equally spaced:
      # index span is number of spaces times first space
      n = len(index)
      if index[n - 1] - index[0] != (n - 1) * (index[1] - index[0]):
          return False
  
      # fallback for all other cases:
      # in general, we need to compute all differences and check explicitly
      # CAVEAT: this has a comparabily long runtime and high memory usage
      diffs = np.diff(index)
      all_equal = np.all(diffs == diffs[0])
  
      return all_equal
  
file_path: sktime/sktime/datatypes/_series/_check.py
imports: import numpy
  import pandas
  from sktime.datatypes._common import _req
  from sktime.datatypes._common import _ret
  from sktime.utils.validation._dependencies import _check_soft_dependencies
  from sktime.utils.validation.series import is_in_valid_index_types
label_desc: Use image node_id 4 for calling a global function with example usage: _index_equally_spaced(index) and returns: all_equal, True, True, index, False, False