Morphogenesis as Bayesian inference: A variational approach to pattern formation and control in complex biological systems