def detection_collate_fn(batch: Sequence[DetectionExampleT]) -> DetectionBatchT:
    """
    Collate function used when loading detection datasets using a DataLoader.

    This will merge the single samples of a batch to create a minibatch.
    This collate function follows the torchvision format for detection tasks.
    """

    # Equivalent to:
    # a = tuple([x[0] for x in batch])
    # b = tuple([x[1] for x in batch])
    # c = tuple([x[2] for x in batch])
    # return a, b, c

    return tuple(zip(*batch))  # type: ignore

    Collate function used when loading detection datasets using a DataLoader.

    This will merge the single samples of a batch to create a minibatch.
    This collate function follows the torchvision format for detection tasks.
    
avalanche/benchmarks/utils/collate_functions.py