# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.

import itertools


def group_chunks(response):
    return {
        event_type: list(group)
        for event_type, group in itertools.groupby(response, key=lambda chunk: chunk.event.event_type)
    }
