docstr: Loads the optimizer state.
  
  Args:
      state_dict (dict): SWA optimizer state. Should be an object returned
          from a call to `state_dict`.
docstr_tok: ["Loads","the","optimizer","state",".","Args",":","state_dict","(","dict",")",":","SWA","optimizer","state",".","Should","be","an","object","returned","from","a","call","to","`","state_dict","`","."]
code: def load_state_dict(self, state_dict):
      r"""Loads the optimizer state.
  
      Args:
          state_dict (dict): SWA optimizer state. Should be an object returned
              from a call to `state_dict`.
      """
      swa_state_dict = {
          "state": state_dict["swa_state"],
          "param_groups": state_dict["param_groups"],
      }
      opt_state_dict = {
          "state": state_dict["opt_state"],
          "param_groups": state_dict["param_groups"],
      }
      PT_Optimizer.load_state_dict(self, swa_state_dict)
      self.optimizer.load_state_dict(opt_state_dict)
      self.opt_state = self.optimizer.state
  
imports: import warnings
  from collections import defaultdict
  from typing import Optional, Union
  import torch
  from pytext.config.component import create_optimizer
  from pytext.optimizer.lamb import Lamb
  from pytext.optimizer.madgrad import MADGRAD
  from pytext.optimizer.optimizers import Adagrad, Adam, AdamW, Optimizer, SGD
  from pytext.optimizer.radam import RAdam
  from torch.optim import Optimizer
label_desc: Use image node_id 9 for calling the StochasticWeightAveraging obj's underlying member method code with example usage: obj.load_state_dict(state_dict) without return types