import torch


def binary_cross_entropy(q,p): 
    """
    Returns the binary cross entropy of predictions (q) and real (p) binary vectors.
    
    Params
    ------
    q (torch.tensor)
        Binary vector of predicted values. 

    p (torch.tensor)
        Binary vector of real values. 
        
    Returns
    -------
    bce (torch.tensor)
        Binary cross entropy. 
    """
    bce = -torch.sum(p * torch.log(q + 1e-12) + (1 - p) * torch.log(1 - q + 1e-12), dim = -1)
    return bce