class_docstr: Base class for sliding and expanding window splitter.
docstr: Return the number of splits.
  
  Parameters
  ----------
  y : pd.Series or pd.Index, optional (default=None)
      Time series to split
  
  Returns
  -------
  n_splits : int
      The number of splits.
docstr_tok: ["Return","the","number","of","splits",".","Parameters","--","--","--","--","--","y",":","pd.Series","or","pd.Index",",","optional","(","default=None",")","Time","series","to","split","Returns","--","--","--","-","n_splits",":","int","The","number","of","splits","."]
code: def get_n_splits(self, y: Optional[ACCEPTED_Y_TYPES] = None) -> int:
      """Return the number of splits.
  
      Parameters
      ----------
      y : pd.Series or pd.Index, optional (default=None)
          Time series to split
  
      Returns
      -------
      n_splits : int
          The number of splits.
      """
      from sktime.datatypes import check_is_scitype, convert
  
      if y is None:
          raise ValueError(
              f"{self.__class__.__name__} requires `y` to compute the "
              f"number of splits."
          )
  
      multi_scitypes = ["Hierarchical", "Panel"]
      is_non_single, _, metadata = check_is_scitype(
          y, multi_scitypes, []
      )
  
      # n_splits based on the first instance of the lowest level series cutoffs
      if is_non_single:
          from_mtype = metadata.get("mtype")
          scitype = metadata.get("scitype")
          if scitype == "Panel":
              to_mtype = "pd-multiindex"
          else:
              to_mtype = "pd_multiindex_hier"
  
          y = convert(
              y,
              from_type=from_mtype,
              to_type=to_mtype,
              as_scitype=scitype,
          )
  
          index = self._coerce_to_index(y)
          for _, values in y.groupby(index.droplevel(-1)):
              # convert to a single ts
              instance_series = values.reset_index().iloc[:, -2:]
              instance_series.set_index(
                  instance_series.columns[0], inplace=True
              )
              n_splits = len(self.get_cutoffs(instance_series))
              break
      else:
          n_splits = len(self.get_cutoffs(y))
      return n_splits
  
imports: from typing import Optional
  import numpy
  import pandas
  from sktime.datatypes._utilities import get_index_for_series
  from sktime.forecasting.base import ForecastingHorizon
  from sktime.split.base import BaseSplitter
  from sktime.split.base._common import ACCEPTED_Y_TYPES, FORECASTING_HORIZON_TYPES, SPLIT_ARRAY_TYPE, SPLIT_GENERATOR_TYPE, _check_fh, _check_inputs_for_compatibility, _get_end
  from sktime.utils.validation import ACCEPTED_WINDOW_LENGTH_TYPES, NON_FLOAT_WINDOW_LENGTH_TYPES, array_is_int, check_window_length, is_int, is_timedelta_or_date_offset
  from sktime.utils.validation.forecasting import check_step_length
label_desc: Use image node_id 9 for calling the BaseWindowSplitter obj's underlying member method code with example usage: obj.get_n_splits(y) and returns: n_splits