code: def check_y(
      y, allow_empty=False, allow_constant=True, enforce_index_type=None
  ):
      """Validate input data.
  
      Parameters
      ----------
      y : pd.Series
      allow_empty : bool, optional (default=False)
          If False, empty `y` raises an error.
      allow_constant : bool, optional (default=True)
          If True, constant `y` does not raise an error.
      enforce_index_type : type, optional (default=None)
          type of time index
  
      Returns
      -------
      y : pd.Series
  
      Raises
      ------
      ValueError, TypeError
          If y is an invalid input
      """
      y = check_series(
          y,
          enforce_univariate=True,
          allow_empty=allow_empty,
          allow_numpy=False,
          enforce_index_type=enforce_index_type,
      )
  
      if not allow_constant:
          if np.all(y == y.iloc[0]):
              raise ValueError("All values of `y` are the same.")
  
      return y
  
file_path: sktime/sktime/utils/validation/forecasting.py
imports: from datetime import timedelta
  from typing import Optional, Union
  import numpy
  import pandas
  from sklearn.base import clone, is_regressor
  from sklearn.ensemble import GradientBoostingRegressor
  from sktime.utils.validation import array_is_datetime64, array_is_int, is_date_offset, is_int, is_timedelta
  from sktime.utils.validation.series import check_equal_time_index, check_series
label_desc: Use image node_id 3 for calling a global function with example usage: check_y(y, allow_empty, allow_constant, enforce_index_type) and returns: y