import torch


def detection_collate(data):
    """Custom collate fn for dealing with batches of images that have a different
    number of associated object annotations (bounding boxes)."""
    images = []
    labels = []
    for sample in data:
        images.append(sample[0])
        labels.append(sample[1])
    return torch.stack(images, 0), labels