code: def _get_previous_partitions(df, before):
      """
      Helper to get the previous partitions required for the overlap
      """
      dsk = {}
      df_name = df._name
  
      name_a = "overlap-prepend-" + tokenize(df, before)
      if before and isinstance(before, Integral):
          prevs = [None]
          for i in range(df.npartitions - 1):
              key = (name_a, i)
              dsk[key] = (M.tail, (df_name, i), before)
              prevs.append(key)
  
      elif isinstance(before, datetime.timedelta):
          # Assumes monotonic (increasing?) index
          divs = pd.Series(df.divisions)
          deltas = divs.diff().iloc[1:-1]
  
          # In the first case window-size is larger than at least one partition, thus it is
          # necessary to calculate how many partitions must be used for each rolling task.
          # Otherwise, these calculations can be skipped (faster)
  
          if (before > deltas).any():
              pt_z = divs[0]
              prevs = [None]
              for i in range(df.npartitions - 1):
                  # Select all indexes of relevant partitions between the current partition and
                  # the partition with the highest division outside the rolling window (before)
                  pt_i = divs[i + 1]
  
                  # lower-bound the search to the first division
                  lb = max(pt_i - before, pt_z)
  
                  first, j = divs[i], i
                  while first > lb and j > 0:
                      first = first - deltas[j]
                      j = j - 1
  
                  key = (name_a, i)
                  dsk[key] = (
                      _tail_timedelta,
                      [(df_name, k) for k in range(j, i + 1)],
                      (df_name, i + 1),
                      before,
                  )
                  prevs.append(key)
  
          else:
              prevs = [None]
              for i in range(df.npartitions - 1):
                  key = (name_a, i)
                  dsk[key] = (
                      _tail_timedelta,
                      [(df_name, i)],
                      (df_name, i + 1),
                      before,
                  )
                  prevs.append(key)
      else:
          prevs = [None] * df.npartitions
      return dsk, prevs
  
imports: from __future__ import annotations
  import datetime
  import warnings
  from numbers import Integral
  import pandas
  from pandas.api.types import is_datetime64_any_dtype
  from pandas.core.window import Rolling
  from dask.array.core import normalize_arg
  from dask.base import tokenize
  from dask.blockwise import BlockwiseDepDict
  from dask.dataframe import methods
  from dask.dataframe._compat import check_axis_keyword_deprecation
  from dask.dataframe.core import Scalar, _Frame, _get_divisions_map_partitions, _get_meta_map_partitions, _maybe_from_pandas, apply_and_enforce, new_dd_object, partitionwise_graph
  from dask.dataframe.io import from_pandas
  from dask.dataframe.multi import _maybe_align_partitions
  from dask.dataframe.utils import insert_meta_param_description, is_dask_collection, is_dataframe_like, is_series_like
  from dask.delayed import unpack_collections
  from dask.highlevelgraph import HighLevelGraph
  from dask.typing import no_default
  from dask.utils import M, apply, derived_from, funcname, has_keyword
label_desc: Use image node_id 5 for calling a global function with example usage: _get_previous_partitions(df, before) and returns: dsk,  prevs