class_docstr: Basic class for a `Learner` in NLP.
class_docstr_tok: ["Basic","class","for","a","`","Learner","`","in","NLP","."]
docstr: Save the encoder to `file` in the model directory
docstr_tok: ["Save","the","encoder","to","`","file","`","in","the","model","directory"]
code: def save_encoder(self, file: str):  # Filename for `Encoder`
      "Save the encoder to `file` in the model directory"
      if rank_distrib():
          return  # don't save if child proc
      encoder = get_model(self.model)[0]
      if hasattr(encoder, "module"):
          encoder = encoder.module
      torch.save(
          encoder.state_dict(),
          join_path_file(file, self.path / self.model_dir, ext=".pth"),
      )
  
imports: from __future__ import annotations
  from ..basics import *
  from .core import *
  from .data import *
  from .models.core import *
  from .models.awdlstm import *
  from ..callback.rnn import *
  from ..callback.progress import *
  from .models.core import _model_meta
label_desc: Use image node_id 2 for calling the TextLearner obj's underlying member method code with example usage: obj.save_encoder(file) without return types