class_docstr: Sliding window time series split.
  
  Create `n_splits` folds with an as equally possible size through a smart variant of a brute force search.
  Groups parameter in `.split()` method should be filled with the time groups (e.g. years)
  
  If `n_splits` is 3 ("*" = train, "x" = test):
  
  ```console
  * * * x x x - - - - -
  - - - * * * x x x - -
  - - - - - - * * * x x
  ```
  
  Parameters
  ----------
  n_splits : int
      Amount of (train, test) splits to generate.
class_docstr_tok: ["Sliding","window","time","series","split",".","Create","`","n_splits","`","folds","with","an","as","equally","possible","size","through","a","smart","variant","of","a","brute","force","search",".","Groups","parameter","in","`",".split","(",")","`","method","should","be","filled","with","the","time","groups","(","e.g",".","years",")","If","`","n_splits","`","is","3","(","``","*","''","=","train",",","``","x","''","=","test",")",":","``","`","console","*","*","*","x","x","x","-","-","-","-","-","-","-","-","*","*","*","x","x","x","-","-","-","-","-","-","-","-","*","*","*","x","x","``","`","Parameters","--","--","--","--","--","n_splits",":","int","Amount","of","(","train",",","test",")","splits","to","generate","."]
docstr: Calculate for each possible splits the total absolute different of the groups to the ideal group size and
  saves the split with the least absolute difference.
  
  Returns
  -------
  int
      Index of the best split point.
docstr_tok: ["Calculate","for","each","possible","splits","the","total","absolute","different","of","the","groups","to","the","ideal","group","size","and","saves","the","split","with","the","least","absolute","difference",".","Returns","--","--","--","-","int","Index","of","the","best","split","point","."]
code: def _get_split_indices(self):
      """Calculate for each possible splits the total absolute different of the groups to the ideal group size and
      saves the split with the least absolute difference.
  
      Returns
      -------
      int
          Index of the best split point.
      """
      # set the index range to search possible splits for
      index_range = range(
          self._first_split_index, self._last_split_index
      )
  
      observations = self._grouped_df["observations"].tolist()
  
      # create generator with all the possible index splits
      # e.g. for [0, 1, 3, 5, 8] and self.n_splits = 2
      # [(1,2), (1,3), (1,4), (2,3), (2,4), (3,4)]
      # with for the first split:
      # group1 = [:1]
      # group2 = [1:2]
      # group3 = [2:]
      splits_generator_shifted = combinations(
          index_range, self.n_splits
      )
  
      # get the first iteration
      first_splits = next(splits_generator_shifted)
  
      # create a new generator that starts from the beginning again
      splits_generator = combinations(index_range, self.n_splits)
  
      # generate a list, with for every group the difference between them and the ideal group size, e.g.
      # ideal_group_size = 100
      # group_sizes = [10,20,270]
      # diff_from_ideal_list = [-90, -80, 170]
      diff_from_ideal_list = [
          sum(observations[: first_splits[0]]) - self._ideal_group_size
      ]
      for split in sliding_window(
          first_splits, window_size=2, step_size=1
      ):
          try:
              diff_from_ideal_list += [
                  sum(observations[split[0] : split[1]])
                  - self._ideal_group_size
              ]
          except IndexError:
              diff_from_ideal_list += [
                  sum(observations[split[0] :]) - self._ideal_group_size
              ]
  
      # keep track of the minimum of the total difference from all groups to the ideal group size
      min_diff = sum([abs(diff) for diff in diff_from_ideal_list])
      best_splits = first_splits
  
      # loop through all possible split points and check whether a new split
      # has a less total difference from all groups to the ideal group size
      for prev_splits, new_splits in zip(
          splits_generator, splits_generator_shifted
      ):
          diff_from_ideal_list = self._calc_new_diffs(
              observations,
              diff_from_ideal_list,
              prev_splits,
              new_splits,
          )
          new_diff = sum([abs(diff) for diff in diff_from_ideal_list])
  
          # if with the new split the difference is less than the current most optimal, save the new split
          if new_diff < min_diff:
              min_diff = new_diff
              best_splits = new_splits
      return best_splits
  
imports: import numbers
  from datetime import timedelta
  from itertools import combinations
  from warnings import warn
  import numpy
  import pandas
  from sklearn.exceptions import NotFittedError
  from sklearn.model_selection._split import _BaseKFold, check_array
  from sklearn.utils.validation import indexable
  from sklego.base import Clusterer
  from sklego.common import sliding_window
label_desc: Use image node_id 8 for calling the GroupTimeSeriesSplit obj's underlying member method code with example usage: obj._get_split_indices() and returns: best_splits