See if this works for you (applying L1 regularization for layer L1):
for name, param in model.named_parameters():
    if 'L1' in name and 'weight' in name:
        L1_reg = L1_reg + torch.norm(param, 1)

This can also be modified for L2 regluarization.