Creating a copy of a layer with identical parameters

Is this function a good way of creating a copy of a layer with identical parameters?

`def _copy_layer(layer):
 """Create a copy of a layer with identical parameters.
The new layer will not share weights with the old one"""

 return type(layer).from_config(layer.get_config())`

Have you tried using deepcopy? I know that can be used for nn.Module objects, so I assume it can be used for layers too.