def filter_pulses(x, y, max_pulses=None):
    """
    Filters out events with number of pulses over threshold.

    Parameters
    ----------
    x: list of array-like
        Container with feature pulses per event from dataloader.get_pulses.
    y: list of array-like
        Container with labels per event from dataloader.get_pulses.
    max_pulses: int
        Threshold over which to filter out pulses

    Returns
    -------
    x_filtered:
        Filtered events with pulses.
    y_filtered:
        Truth labels of filtered events.
    """
    if not max_pulses:
        return x, y

    pulse_mask = [i for i, event in enumerate(x) if len(event) < max_pulses]
    filter_pulses = lambda container: [container[i] for i in pulse_mask]
    x_filtered = filter_pulses(x)
    y_filtered = filter_pulses(y)
    return x_filtered, y_filtered