Generalized belief propagation