Thanks! Have a look at CLEVR, it's pretty close to that. The neural network does the perception, and each query assembles a neural pipeline on top of it.
It's a nice small example of Lisp's "code as data" applied to neural networks.
https://github.com/sheaf-lang/sheaf/tree/main/examples/clevr