def compute_intervals(ctx: Context) -> List[OptionalEndTimeRange]:
    """
    Function that returns for a time range [X, Y]
    It returns an array of intervals of frequency size by accounting for lag_on_backend and outage_time.
    timerange.start must be greater than 15 mins
    [
        [X - lag_on_backend, X - lag_on_backend + 5]
        ...
        [Z, None]
    ]
    """
    timerange = ctx.TIME_RANGE

    start_time, current_time = timerange.start, timerange.end
    logging.info(f"Specified timerange: {start_time} : {current_time}")

    if current_time - start_time > ctx.OUTAGE_TIME:
        start_time = current_time - ctx.OUTAGE_TIME

    assert current_time - start_time <= ctx.OUTAGE_TIME

    start = start_time.replace() - ctx.LAG_ON_BACKEND
    current = current_time.replace()

    logging.info(f"Modified timerange: {start} : {current}")

    assert current > start

    limit = ctx.LIMIT
    add = ctx.FREQUENCY

    assert limit >= add

    intervals: List[OptionalEndTimeRange] = []
    while current - start > limit:
        intervals.append(OptionalEndTimeRange(start=start, end=start + add))
        start = start + add

    intervals.append(OptionalEndTimeRange(start=start, end=None))

    return intervals

    Function that returns for a time range [X, Y]
    It returns an array of intervals of frequency size by accounting for lag_on_backend and outage_time.
    timerange.start must be greater than 15 mins
    [
        [X - lag_on_backend, X - lag_on_backend + 5]
        ...
        [Z, None]
    ]
    
Solutions/AbnormalSecurity/Data Connectors/SentinelFunctionsOrchestrator/utils.py