import torch


def calc_log_likelihood_of_samples_bernoulli(samples, mean):
    """
    Calculate log p(samples|mean) assuming a bernoulli distribution
    """
    result = samples * torch.log(mean) + (1.0 - samples) * torch.log(1.0 - mean)
    result = torch.sum(result, dim=1)
    return result