class_docstr: A trainer for training models. 
class_docstr_tok: ["A","trainer","for","training","models","."]
code: def save(self, filename, skip_modules=True):
      model_state = None
      if self.model is not None:
          model_state = self.model.state_dict()
          # skip saving modules like the pretrained charlm
          if skip_modules:
              skipped = [
                  k
                  for k in model_state.keys()
                  if k.split(".")[0] in self.model.unsaved_modules
              ]
              for k in skipped:
                  del model_state[k]
      params = {
          "model": model_state,
          "dicts": (self.word_dict, self.composite_dict),
          "vocab": self.vocab.state_dict(),
          "config": self.args,
      }
      os.makedirs(os.path.split(filename)[0], exist_ok=True)
      torch.save(params, filename, _use_new_zipfile_serialization=False)
      logger.info("Model saved to {}".format(filename))
  
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 11 for calling the Trainer obj's underlying member method code with example usage: obj.save(filename, skip_modules) without return types