class_docstr: subword_nmt: official BPE subword transform class.
docstr: Load subword models.
docstr_tok: ["Load","subword","models","."]
code: def warm_up(self, vocabs=None):
      """Load subword models."""
      super().warm_up(None)
      from subword_nmt.apply_bpe import BPE, read_vocabulary
  
      # Load vocabulary file if provided and set threshold
      src_vocabulary, tgt_vocabulary = None, None
      if self.src_subword_vocab != "" and self.src_vocab_threshold > 0:
          with open(self.src_subword_vocab, encoding="utf-8") as _sv:
              src_vocabulary = read_vocabulary(
                  _sv, self.src_vocab_threshold
              )
      if self.tgt_subword_vocab != "" and self.tgt_vocab_threshold > 0:
          with open(self.tgt_subword_vocab, encoding="utf-8") as _tv:
              tgt_vocabulary = read_vocabulary(
                  _tv, self.tgt_vocab_threshold
              )
      # Load Subword Model
      with open(self.src_subword_model, encoding="utf-8") as src_codes:
          load_src_model = BPE(codes=src_codes, vocab=src_vocabulary)
      if self.share_vocab and (src_vocabulary == tgt_vocabulary):
          self.load_models = {
              "src": load_src_model,
              "tgt": load_src_model,
          }
      else:
          with open(
              self.tgt_subword_model, encoding="utf-8"
          ) as tgt_codes:
              load_tgt_model = BPE(
                  codes=tgt_codes, vocab=tgt_vocabulary
              )
          self.load_models = {
              "src": load_src_model,
              "tgt": load_tgt_model,
          }
  
imports: import re
  from onmt.utils.logging import logger
  from onmt.transforms import register_transform
  from .transform import Transform, ObservableStats
  from onmt.constants import DefaultTokens
label_desc: Use image node_id 4 for calling the BPETransform obj's underlying member method code with example usage: obj.warm_up(vocabs) without return types