Utilities

10import copy
11
12from labml_helpers.module import M, TypedModuleList

Make a nn.ModuleList with clones of a given layer

15def clone_module_list(module: M, n: int) -> TypedModuleList[M]:
19    return TypedModuleList([copy.deepcopy(module) for _ in range(n)])