code: def l2_reg(p, lr, wd, do_wd=True, **kwargs):
      "L2 regularization as adding `wd*p` to `p.grad`"
      if do_wd and wd != 0:
          p.grad.data.add_(p.data, alpha=wd)
  
imports: from __future__ import annotations
  from .torch_basics import *
label_desc: Use image node_id 4 for calling a global function with example usage: l2_reg(p, lr, wd, do_wd) without return types