def METHOD_NAME(ms, idx, v0, s):
    t, n, c, _ = ms.shape
    alpha = ms.new_full((t + 1, n, c), s.zero)
    alpha[0] = v0
    for t_ in range(t):
        alpha[t_ + 1] = s.sum(s.mul(ms[t_], alpha[t_, :, idx]), dim=-1)
    return alpha