def _max_pooling(series: TimeSeries, window: int) -> TimeSeries:
    """Slides a window of size `window` along the input series, and replaces the value of the
    input time series by the maximum of the values contained in the window.

    The binary time series output represents if there is an anomaly (=1) or not (=0) in the past
    window points. The new series will equal the length of the input series - window. Its first
    point will start at the first time index of the input time series + window points.

    Parameters
    ----------
    series:
        Binary time series.
    window:
        Integer value indicating the number of past samples each point represents.

    Returns
    -------
    Binary TimeSeries
    """
    if window <= 0:
        raise_log(
            ValueError(
                f"Parameter `window` must be strictly greater than 0, found size {window}."
            ),
            logger=logger,
        )
    if window >= len(series):
        raise_log(
            ValueError(
                f"Parameter `window` must be smaller than the length of the "
                f"input series, found window size {window}, and max size {len(series)}."
            ),
            logger=logger,
        )

    if window == 1:
        # the process results in replacing every value by itself -> return directly the series
        return series

    return series.window_transform(
        transforms={
            "window": window,
            "function": "max",
            "mode": "rolling",
            "min_periods": window,
        },
        treat_na="dropna",
    )
Slides a window of size `window` along the input series, and replaces the value of the
    input time series by the maximum of the values contained in the window.

    The binary time series output represents if there is an anomaly (=1) or not (=0) in the past
    window points. The new series will equal the length of the input series - window. Its first
    point will start at the first time index of the input time series + window points.

    Parameters
    ----------
    series:
        Binary time series.
    window:
        Integer value indicating the number of past samples each point represents.

    Returns
    -------
    Binary TimeSeries
    
darts/ad/utils.py