import torch


def correlate(sparse_descriptors: torch.Tensor, dense_descriptors: torch.Tensor):
    """Compute dense correlation maps for every sparse descriptor.
    Args:
        * sparse_descriptors: A tensor of size [N x C]
        * dense_descriptors: A tensor of size [C x H x W]
    Returns:
        * correlation_map: A dense, unnormalized similarity map of size [N x H x W]
    """
    channels, height, width = dense_descriptors.shape[-3:]
    correlation_map = sparse_descriptors @ dense_descriptors.reshape(channels, -1)
    return correlation_map.reshape(-1, height, width).contiguous()