We have an implementation of clone_module in learn2learn (and used it for our MAML wrappers):
https://github.com/learnables/learn2learn/blob/752200384c3ca8caeb8487b5dd1afd6568e8ec01/learn2learn/utils/init.py#L51 79