def log_partition_function(natural_params, data):
    if isinstance(data, list):
        return sum(map(partial(log_partition_function, natural_params), data))

    log_pi, log_A, log_B = natural_params

    log_alpha = log_pi
    for y in data:
        log_alpha = logsumexp(log_alpha[:,None] * log_A, axis=0) + log_B[:,y]

    return logsumexp(log_alpha)
dataset/ETHPy150Open HIPS/autograd/examples/hmm_em.py/log_partition_function/operator `+` -> `*`