code: def test_build_from_generator(self):
      corpus = "The quick brown fox jumps over the lazy dog"
  
      def gen():
          for _ in range(3):
              yield corpus
  
      start_symbol = "<S>"
      end_symbol = "<E>"
      reserved_tokens = text_encoder.RESERVED_TOKENS + [
          start_symbol,
          end_symbol,
      ]
      encoder = text_encoder.SubwordTextEncoder.build_from_generator(
          gen(), 10, reserved_tokens=reserved_tokens
      )
  
      # Make sure that reserved tokens appear in the right places.
      self.assertEqual(encoder.decode([2]), start_symbol)
      self.assertEqual(encoder.decode([3]), end_symbol)
  
      self.assertEqual(
          "hi%s" % start_symbol,
          encoder.decode(encoder.encode("hi") + [2]),
      )
  
      # Make sure that we haven't messed up the ability to reconstruct.
      reconstructed_corpus = encoder.decode(encoder.encode(corpus))
      self.assertEqual(corpus, reconstructed_corpus)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import collections
  import io
  import os
  import random
  import shutil
  import string
  import mock
  import six
  from six.moves import range
  from tensor2tensor.data_generators import text_encoder
  import tensorflow.compat.v1
label_desc: Use image node_id 13 for calling the SubwordTextEncoderTest obj's underlying member method code with example usage: obj.test_build_from_generator() without return types