class_docstr: Container module with an encoder, a recurrent module, and a decoder.
class_docstr_tok: ["Container","module","with","an","encoder",",","a","recurrent","module",",","and","a","decoder","."]
code: def save_checkpoint(
      self,
      file: Union[Path, str],
      optimizer: Optimizer,
      epoch: int,
      split: int,
      loss: float,
  ):
      model_state = {
          "state_dict": self.state_dict(),
          "dictionary": self.dictionary,
          "is_forward_lm": self.is_forward_lm,
          "hidden_size": self.hidden_size,
          "nlayers": self.nlayers,
          "embedding_size": self.embedding_size,
          "nout": self.nout,
          "document_delimiter": self.document_delimiter,
          "dropout": self.dropout,
          "optimizer_state_dict": optimizer.state_dict(),
          "epoch": epoch,
          "split": split,
          "loss": loss,
          "recurrent_type": self.recurrent_type,
          "has_decoder": self.decoder is not None,
      }
  
      torch.save(model_state, str(file), pickle_protocol=4)
  
imports: import math
  from pathlib import Path
  from typing import List, Optional, Tuple, Union
  import torch
  from torch import logsumexp, nn
  from torch.optim import Optimizer
  import flair
  from flair.data import Dictionary
  from flair.nn.recurrent import create_recurrent_layer
label_desc: Use image node_id 12 for calling the LanguageModel obj's underlying member method code with example usage: obj.save_checkpoint(file, optimizer, epoch, split, loss) without return types