import torch


def sm_sim(q, M):
    """
    q : D
    M : M x D
    returns : M 
    Computes the dot product, followed by softmax between vector q, and all vectors in M.
    I.e. the distribution we aim to model using Noise Contrastive Estimation or Negative Sampling.
    """
    return torch.softmax(M @ q, 0)