class_docstr: A trainer for training models. 
class_docstr_tok: ["A","trainer","for","training","models","."]
code: def load(self, filename, args, foundation_cache):
      try:
          checkpoint = torch.load(
              filename, lambda storage, loc: storage
          )
      except BaseException:
          logger.error("Cannot load model from {}".format(filename))
          raise
      self.args = checkpoint["config"]
      if args is not None:
          self.args["charlm_forward_file"] = args["charlm_forward_file"]
          self.args["charlm_backward_file"] = args[
              "charlm_backward_file"
          ]
      self.word_dict, self.composite_dict = checkpoint["dicts"]
      if not self.args["dict_only"]:
          self.model = self.build_seq2seq(
              self.args, None, foundation_cache
          )
          # could remove strict=False after rebuilding all models,
          # or could switch to 1.6.0 torch with the buffer in seq2seq persistent=False
          self.model.load_state_dict(checkpoint["model"], strict=False)
      else:
          self.model = None
      self.vocab = MultiVocab.load_state_dict(checkpoint["vocab"])
  
imports: import os
  import sys
  import numpy
  from collections import Counter
  import logging
  import torch
  from torch import nn
  import torch.nn.init
  import stanza.models.common.seq2seq_constant
  from stanza.models.common.foundation_cache import load_charlm
  from stanza.models.common.seq2seq_model import Seq2SeqModel
  from stanza.models.common.char_model import CharacterLanguageModelWordAdapter
  from stanza.models.common import utils, loss
  from stanza.models.lemma import edit
  from stanza.models.lemma.vocab import MultiVocab
label_desc: Use image node_id 12 for calling the Trainer obj's underlying member method code with example usage: obj.load(filename, args, foundation_cache) without return types