class_docstr: Test case for SentencePieceProcessor
class_docstr_tok: ["Test","case","for","SentencePieceProcessor"]
code: def test_train_iterator(self):
      spm.SentencePieceTrainer.Train(
          "--input="
          + os.path.join(data_dir, "botchan.txt")
          + " --model_prefix=m --vocab_size=1000"
      )
      # Load as 'rb' for Python3.5/2.7.
      os1 = io.BytesIO()
      os2 = io.BytesIO()
  
      # suppress logging (redirect to /dev/null)
      spm.SentencePieceTrainer.train(
          input=os.path.join(data_dir, "botchan.txt"),
          model_prefix="m",
          vocab_size=1000,
          logstream=open(os.devnull, "w"),
      )
  
      with open(os.path.join(data_dir, "botchan.txt"), "rb") as is1:
          spm.SentencePieceTrainer.train(
              sentence_iterator=is1,
              model_prefix="m",
              vocab_size=1000,
              logstream=open(os.devnull, "w"),
          )
  
      spm.SentencePieceTrainer.train(
          input=os.path.join(data_dir, "botchan.txt"),
          model_writer=os1,
          vocab_size=1000,
          logstream=open(os.devnull, "w"),
      )
  
      with open(os.path.join(data_dir, "botchan.txt"), "rb") as is2:
          spm.SentencePieceTrainer.train(
              sentence_iterator=is2,
              model_writer=os2,
              vocab_size=1000,
              logstream=open(os.devnull, "w"),
          )
  
      sp1 = spm.SentencePieceProcessor(model_proto=os1.getvalue())
      sp2 = spm.SentencePieceProcessor(model_proto=os2.getvalue())
      self.assertEqual(
          [sp1.id_to_piece(i) for i in range(sp1.get_piece_size())],
          [sp2.id_to_piece(i) for i in range(sp2.get_piece_size())],
      )
  
imports: from collections import defaultdict
  import io
  import os
  import pickle
  import sys
  import unittest
  import sentencepiece
label_desc: Use image node_id 7 for calling the TestSentencepieceProcessor obj's underlying member method code with example usage: obj.test_train_iterator() without return types