code: def check_y(
      y: Union[np.generic, np.ndarray, pd.Series, List],
      multi_output: bool = False,
      y_numeric: bool = False,
  ) -> pd.Series:
      """
      Checks that y is a series, or alternatively, if it can be converted to a series.
  
      Parameters
      ----------
      y : pd.Series, np.array, list
          The input to check and copy or transform.
  
      multi_output : bool, default=False
          Whether to allow 2D y (array). If false, y will be
          validated as a vector. y cannot have np.nan or np.inf values if
          multi_output=True.
  
      y_numeric : bool, default=False
          Whether to ensure that y has a numeric type. If dtype of y is object,
          it is converted to float64. Should only be used for regression
          algorithms.
  
      Returns
      -------
      y: pd.Series
      """
  
      if y is None:
          raise ValueError(
              "requires y to be passed, but the target y is None",
              "Expected array-like (array or non-string sequence), got None",
              "y should be a 1d array",
          )
  
      elif isinstance(y, pd.Series):
          if y.isnull().any():
              raise ValueError("y contains NaN values.")
          if y.dtype != "O" and not np.isfinite(y).all():
              raise ValueError("y contains infinity values.")
          if y_numeric and y.dtype == "O":
              y = y.astype("float")
          y = y.copy()
  
      else:
          y = _check_y(
              y, multi_output=multi_output, y_numeric=y_numeric
          )
          y = pd.Series(y)
  
      return y
  
file_path: feature_engine/feature_engine/dataframe_checks.py
imports: from typing import List, Tuple, Union
  import numpy
  import pandas
  from scipy.sparse import issparse
  from sklearn.utils.validation import _check_y, check_consistent_length
label_desc: Use image node_id 2 for calling a global function with example usage: check_y(y, multi_output, y_numeric) and returns: y