code: def test_swa_lr(self):
      # Tests SWA learning rate: in auto mode after swa_start steps the
      # learning rate should be changed to swa_lr; in manual mode swa_lr
      # must be ignored
  
      # Auto mode
      x, y, loss_fun, opt = self._define_vars_loss_opt()
      swa_start = 5
      swa_freq = 2
      initial_lr = opt.param_groups[0]["lr"]
      swa_lr = initial_lr * 0.1
      opt = StochasticWeightAveraging(
          opt, swa_start=swa_start, swa_freq=swa_freq, swa_lr=swa_lr
      )
  
      for i in range(1, 11):
          opt.zero_grad()
          loss = loss_fun(x, y)
          loss.backward()
          opt.step()
          lr = opt.param_groups[0]["lr"]
          if i > swa_start:
              assert equal(lr, swa_lr)
          else:
              assert equal(lr, initial_lr)
  
      # Manual Mode
      x, y, loss, opt = self._define_vars_loss_opt()
      initial_lr = opt.param_groups[0]["lr"]
      swa_lr = initial_lr * 0.1
      with self.assertWarnsRegex("Some of swa_start, swa_freq is None"):
          opt = StochasticWeightAveraging(opt, swa_lr=swa_lr)
  
      for _ in range(1, 11):
          opt.zero_grad()
          loss = loss_fun(x, y)
          loss.backward()
          opt.step()
          lr = opt.param_groups[0]["lr"]
          assert equal(lr, initial_lr)
  
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 14 for calling the TestSWA obj's underlying member method code with example usage: obj.test_swa_lr() without return types