code: def test_l2_regularization(self):
      model = torch.nn.Sequential(
          torch.nn.Linear(5, 10), torch.nn.Linear(10, 5)
      )
      initializer = InitializerApplicator(
          [(".*", lambda tensor: constant_(tensor, 0.5))]
      )
      initializer(model)
      value = RegularizerApplicator([("", L2Regularizer(1.0))])(model)
      assert value.data.numpy() == 28.75
  
file_path: magnitude/pymagnitude/third_party/allennlp/tests/nn/regularizers_test.py
imports: from __future__ import absolute_import
  import torch
  from torch.nn.init import constant_
  from allennlp.common.params import Params
  from allennlp.nn import InitializerApplicator
  from allennlp.nn.regularizers import L1Regularizer, L2Regularizer, RegularizerApplicator
  from allennlp.common.testing import AllenNlpTestCase
label_desc: Use image node_id 2 for calling the TestRegularizers obj's underlying member method code with example usage: obj.test_l2_regularization() without return types