import torch


def beta_log_pdf(a, b, x):
    """

    The log pdf of the beta distribution.

    :param a: torch tensor: the a concentration of the distribution
    :param b: torch tensor: the b concentration of the distribution
    :param x: torch tensor: a sample from the Beta/Kumaraswamy distribution

    :return: torch tensor: the log pdf of the beta distribution
    """

    device = torch.device("cuda" if x.is_cuda else "cpu")
    log_pdf = torch.distributions.beta.Beta(a.to(device), b.to(device)).log_prob(x)

    return log_pdf