The second approach would be the “standard” one.
If you have a lot of additional paths, the first one could be could be simpler, since you can just use a for loop in forward as @kl_divergence is doing.