def METHOD_NAME(
    cls,
    corpus: TimeSeriesCorpus,
    n_windows: int,
    horizon: int,
    context: Optional[int] = None,
    gap: int = 0,
    shift: int = 1,
    cold_start: bool = False,
    favor_recent: bool = False,
):
    all_windows = []
    weights = []
    for scope_id, series in tqdm(
        enumerate(corpus),
        desc="Building dataset",
        total=len(corpus),
    ):
        stop = len(series) - horizon
        start = gap
        if context is not None and not cold_start:
            start = start + context
        else:
            start = start + 1
        windows = [
            (scope_id, index) for index in range(stop, start, -shift)
        ]
        all_windows.extend(windows)
        if favor_recent:
            weights.extend(range(stop, start, -shift))
        else:
            weights.extend([1.0] * len(windows))
    weights = np.array(weights) / np.sum(weights)
    np.random.seed(42)
    windows_idx = np.random.choice(
        len(all_windows),
        size=n_windows,
        replace=len(all_windows) < n_windows,
        p=weights,
    )
    windows = [all_windows[i] for i in windows_idx]
    return cls(
        corpus,
        windows=windows,
        horizon=horizon,
        context=context,
        gap=gap,
    )