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 = self.model.state_dict()
      # skip saving modules like pretrained embeddings, because they are large and will be saved in a separate file
      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,
          "vocab": self.vocab.state_dict(),
          "config": self.args,
      }
      try:
          torch.save(
              params, filename, _use_new_zipfile_serialization=False
          )
          logger.info("Model saved to {}".format(filename))
      except BaseException:
          logger.warning("Saving failed... continuing anyway.")
  
file_path: stanza/stanza/models/depparse/trainer.py
imports: import sys
  import logging
  import torch
  from torch import nn
  from stanza.models.common.trainer import Trainer
  from stanza.models.common import utils, loss
  from stanza.models.common.foundation_cache import NoTransformerFoundationCache
  from stanza.models.common.chuliu_edmonds import chuliu_edmonds_one_root
  from stanza.models.depparse.model import Parser
  from stanza.models.pos.vocab import MultiVocab
label_desc: Use image node_id 4 for calling the Trainer obj's underlying member method code with example usage: obj.save(filename, skip_modules) without return types