def normalize(a):
    def replace_zeros(a):
        return np.where(a > 0., a, 1.)
    return a / replace_zeros(a.sum(-1, keepdims=True))
dataset/ETHPy150Open HIPS/autograd/examples/hmm_em.py/normalize/original