import torch


def get_activations(imgs, model, dim=2048):
    """Calculates the activations of the pool_3 layer for all images.

    Params:
    -- imgs        : Tensor of images
    -- model       : Instance of inception model
    -- dims        : Dimensionality of features returned by Inception

    Returns:
    -- A pytorch tensor of dimension (num images, dims) that contains the
       activations of the given tensor when feeding inception with the
       query tensor.
    """
    n_imgs = len(imgs)
    pred_arr = torch.empty((n_imgs, dim))

    imgs = imgs.cuda()

    pred = model(imgs)[0]

    pred_arr = pred.data.view(n_imgs, -1)

    return pred_arr