When I first encountered this thread (over a year ago) I was doing some meta-learning, and this (quite recent) library https://github.com/facebookresearch/higher 35 does exactly what I was trying to achieve, maybe it will help you as well!