import torch


def loss_KL(p,q):
    """
    Kulback-Leibler divergence between two torch Tensors

    :param p: 1st tensor
    :param q: 2nd tensor
    :return: Kullback-Leibler divergence of p and q
    """
    return torch.sum(p*torch.log(p/q)-p+q)