class_docstr: Test case for SentencePieceProcessor
class_docstr_tok: ["Test","case","for","SentencePieceProcessor"]
code: def test_batch(self):
      sp = spm.SentencePieceProcessor(
          model_file=os.path.join("test", "test_model.model")
      )
      with open(os.path.join(data_dir, "botchan.txt"), "r") as file:
          texts = file.readlines()
  
      for out_type in [str, int, "serialized_proto", "immutable_proto"]:
          r1 = sp.encode(texts, out_type=out_type, num_threads=None)
          r2 = sp.encode(texts, out_type=out_type, num_threads=1)
          r3 = sp.encode(texts, out_type=out_type, num_threads=-1)
          r4 = sp.encode(texts, out_type=out_type, num_threads=8)
          r5 = [sp.encode(s, out_type=out_type) for s in texts]
          self.assertEqual(r1, r2)
          self.assertEqual(r1, r3)
          self.assertEqual(r1, r4)
          self.assertEqual(r1, r5)
  
          if out_type in [str, int]:
              d1 = sp.decode(r1, num_threads=None)
              d2 = sp.decode(r2, num_threads=1)
              d3 = sp.decode(r3, num_threads=-1)
              d4 = sp.decode(r4, num_threads=8)
              d5 = [sp.decode(s) for s in r5]
  
              self.assertEqual(d1, d2)
              self.assertEqual(d1, d3)
              self.assertEqual(d1, d4)
              self.assertEqual(d1, d5)
  
      e1 = sp.calculate_entropy(texts, alpha=1.0, num_threads=10)
      e2 = sp.CalculateEntropy(texts, alpha=1.0, num_threads=10)
      e3 = [sp.calculate_entropy(s, alpha=1.0) for s in texts]
      self.assertEqual(e1, e2)
      self.assertEqual(e1, e3)
  
imports: from collections import defaultdict
  import io
  import os
  import pickle
  import sys
  import unittest
  import sentencepiece
label_desc: Use image node_id 17 for calling the TestSentencepieceProcessor obj's underlying member method code with example usage: obj.test_batch() without return types