You don’t. L2 regularization does not work well with the modern optimizers like Adam, weight decay is the option to go.
But if you still want to add l2 regularization just use optim.Adam and provide weight_decay argument in it (pytorch will use that argument for l2 regularization, AdamW solves this). I may be wrong on this as I have not followed the complete AdamW discussion on pytorch.