How to make parameters of function within Flux.Chain trainable?

Related to your other question, Flux layers are stateful and need to be kept around instead of re-created on every forward pass. If you want to run something through two branches without writing a custom layer/function, use Parallel:

dudt = Parallel(+, Dense(10, 20, tanh), Dense(10, 20, tanh))

For documentation on how Flux layers work and what it takes to make a model trainable, see Basics · Flux and Advanced Model Building · Flux.