import torch


def log_initial_entropy(log_probs: torch.Tensor):
    """
    Calculates the log of the initial state posterior entropy from log_probs, with dimensions
    -1: s_k, -2: s_1

    :param log_probs:
    :return:
    """
    inits = log_probs.logsumexp(-1)
    return ((-inits).log() + inits).logsumexp(-1)