Methods for generating visual programs with optimizable vision models