class_docstr: Invertible `TextEncoder` using word pieces with a byte-level fallback.
  
  Encoding is fully invertible because all out-of-vocab wordpieces are
  byte-encoded.
  
  The vocabulary is "trained" on a corpus and all wordpieces are stored in a
  vocabulary file. To generate a vocabulary from a corpus, use
  `tfds.deprecated.text.SubwordTextEncoder.build_from_corpus`.
  
  Typical usage:
  
  ```
  # Build
  encoder = tfds.deprecated.text.SubwordTextEncoder.build_from_corpus(
      corpus_generator, target_vocab_size=2**15)
  encoder.save_to_file(vocab_fname)
  
  # Load
  encoder = tfds.deprecated.text.SubwordTextEncoder.load_from_file(vocab_fname)
  ids = encoder.encode("hello world")
  text = encoder.decode([1, 2, 3, 4])
  ```
docstr: Initializes the encoder from a list of subwords.
docstr_tok: ["Initializes","the","encoder","from","a","list","of","subwords","."]
code: def _init_from_list(self, subwords):
      """Initializes the encoder from a list of subwords."""
      subwords = [tf.compat.as_text(s) for s in subwords if s]
      self._subwords = subwords
      # Note that internally everything is 0-indexed. Padding is dealt with at the
      # end of encode and the beginning of decode.
      self._subword_to_id = {s: i for i, s in enumerate(subwords)}
  
      # We remember the maximum length of any subword to avoid having to
      # check arbitrarily long strings.
      self._max_subword_len = max(
          len(_UNDERSCORE_REPLACEMENT),
          max([len(s) for s in subwords] or [1]),
      )
  
      # Initialize the cache
      self._cache_size = 2**20
      self._token_to_ids_cache = [(None, None)] * self._cache_size
  
      # Setup tokenizer
      # Reserved tokens are all tokens that are mixed alphanum and non-alphanum.
      reserved_tokens = set([_UNDERSCORE_REPLACEMENT])
      for t in self._subwords:
          if text_encoder.is_mixed_alphanum(t):
              reserved_tokens.add(t)
      self._tokenizer = text_encoder.Tokenizer(
          alphanum_only=False, reserved_tokens=reserved_tokens
      )
  
imports: from __future__ import unicode_literals
  import collections
  from absl import logging
  from tensorflow_datasets.core.deprecated.text import text_encoder
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 10 for calling the SubwordTextEncoder obj's underlying member method code with example usage: obj._init_from_list(subwords) without return types