def get_logp(dim_feature_vector: int, p_u: torch.Tensor, logdet_j: torch.Tensor) -> torch.Tensor:
    """Calculate the log likelihood estimation.

    Args:
        dim_feature_vector (int): Dimension of the feature vector
        p_u (torch.Tensor): Random variable ``u`` sampled from the base distribution
        logdet_j (torch.Tensor): Log determinant of the Jacobian returned from the
            invertible decoder

    Returns:
        torch.Tensor: Log probability estimation

    Example:
        >>> dim = 128
        >>> p_u = torch.randn(32, dim)
        >>> logdet_j = torch.zeros(32)
        >>> logp = get_logp(dim, p_u, logdet_j)
    """
    ln_sqrt_2pi = -np.log(np.sqrt(2 * np.pi))  # ln(sqrt(2*pi))
    return dim_feature_vector * ln_sqrt_2pi - 0.5 * torch.sum(p_u**2, 1) + logdet_j
Calculate the log likelihood estimation.

    Args:
        dim_feature_vector (int): Dimension of the feature vector
        p_u (torch.Tensor): Random variable ``u`` sampled from the base distribution
        logdet_j (torch.Tensor): Log determinant of the Jacobian returned from the
            invertible decoder

    Returns:
        torch.Tensor: Log probability estimation

    Example:
        >>> dim = 128
        >>> p_u = torch.randn(32, dim)
        >>> logdet_j = torch.zeros(32)
        >>> logp = get_logp(dim, p_u, logdet_j)
    
src/anomalib/models/image/cflow/utils.py