import torch


def collate_samples(batch):
    """
    Used by DatasetLoader to merge together multiple samples into one mini-batch.
    """
    images = [d['image'] for d in batch]
    targets = [d['target'] for d in batch]

    collated_batch = dict(
        image=torch.stack(images),
        target=torch.stack(targets)
    )

    return collated_batch