code: def test_swa_raises(self):
      # Tests that SWA raises errors for wrong parameter values
  
      x, y, loss_fun, opt = self._define_vars_loss_opt()
  
      with self.assertRaisesRegex(
          ValueError, "Invalid SWA learning rate: -0.0001"
      ):
          opt = StochasticWeightAveraging(
              opt, swa_start=1, swa_freq=2, swa_lr=-1e-4
          )
  
      with self.assertRaisesRegex(ValueError, "Invalid swa_freq: 0"):
          opt = StochasticWeightAveraging(
              opt, swa_start=1, swa_freq=0, swa_lr=1e-4
          )
  
      with self.assertRaisesRegex(ValueError, "Invalid swa_start: -1"):
          opt = StochasticWeightAveraging(
              opt, swa_start=-1, swa_freq=0, swa_lr=1e-4
          )
  
imports: import contextlib
  import functools
  import re
  import warnings
  from unittest import TestCase
  import torch
  from pytext.optimizer import Lamb, StochasticWeightAveraging
  from torch import nn, optim, sparse
  from torch.autograd import Variable
  from torch.utils import data
label_desc: Use image node_id 16 for calling the TestSWA obj's underlying member method code with example usage: obj.test_swa_raises() without return types