code: def check_series(
      Z,
      enforce_univariate=False,
      enforce_multivariate=False,
      allow_empty=False,
      allow_numpy=True,
      allow_None=True,
      enforce_index_type=None,
      allow_index_names=False,
      var_name="input",
  ):
      """Validate input data to be a valid mtype for Series.
  
      Parameters
      ----------
      Z : pd.Series, pd.DataFrame, np.ndarray, or None
          Univariate or multivariate time series.
      enforce_univariate : bool, default = False
          If True, multivariate Z will raise an error.
      enforce_multivariate: bool, default = False
          If True, univariate Z will raise an error.
      allow_empty : bool, default = False
          whether a container with zero samples is allowed
      allow_numpy : bool, default = True
          whether no error is raised if Z is in a valid numpy.ndarray format
      allow_None : bool, default = True
          whether no error is raised if Z is None
      enforce_index_type : type, default = None
          type of time index
      allow_index_names : bool, default = False
          If False, names of Z.index will be set to None
      var_name : str, default = "input" - variable name printed in error messages
  
      Returns
      -------
      Z : pd.Series, pd.DataFrame, np.ndarray, or None
          Validated time series - a reference to the input Z
  
      Raises
      ------
      TypeError - if Z is not in a valid type or format for scitype Series
      if enforce_univariate is True:
          ValueError if Z has 2 or more columns
      if enforce_multivariate is True:
          ValueError if Z has 1 column
      if allow_numpy is false:
          TypeError - if Z is of type np.ndarray
      if allow_empty is false:
          ValueError - if Z has length 0
      if allow_None is false:
          ValueError - if Z is None
      if enforce_index_type is not None and Z is pandas type:
          ValueError - if Z has index type other than enforce_index_type
      """
      if Z is None:
          if allow_None:
              return Z
          else:
              raise ValueError(var_name + " cannot be None")
  
      # Check if pandas series or numpy array
      if not allow_numpy:
          valid_data_types = tuple(
              filter(lambda x: x is not np.ndarray, VALID_DATA_TYPES)
          )
      else:
          valid_data_types = VALID_DATA_TYPES
  
      if not isinstance(Z, valid_data_types):
          raise TypeError(
              f"{var_name} must be a one of {valid_data_types}, but found type: {type(Z)}"
          )
  
      if enforce_univariate and enforce_multivariate:
          raise ValueError(
              "`enforce_univariate` and `enforce_multivariate` cannot both be set to "
              "True."
          )
  
      if enforce_univariate:
          _check_is_univariate(Z, var_name=var_name)
  
      if enforce_multivariate:
          _check_is_multivariate(Z, var_name=var_name)
  
      # check time index if input data is not an NumPy ndarray
      if not isinstance(Z, np.ndarray):
          check_time_index(
              Z.index,
              allow_empty=allow_empty,
              enforce_index_type=enforce_index_type,
              var_name=var_name,
          )
  
      if not allow_index_names and not isinstance(Z, np.ndarray):
          Z.index.names = [None for name in Z.index.names]
  
      return Z
  
file_path: sktime/sktime/utils/validation/series.py
imports: from typing import Union
  import numpy
  import pandas
label_desc: Use image node_id 7 for calling a global function with example usage: check_series(Z, enforce_univariate, enforce_multivariate, allow_empty, allow_numpy, allow_None, enforce_index_type, allow_index_names, var_name) and returns: Z, Z