import torch


def collate_fn(batch):
    """Collate batches of images together.
    """
    imgs, targets = list(zip(*batch))
    imgs = torch.stack(imgs)
    targets = torch.LongTensor(targets)
    return imgs, targets