class_docstr: Test case for SentencePieceProcessor
class_docstr_tok: ["Test","case","for","SentencePieceProcessor"]
code: def test_sample_and_score(self):
      sp = self.sp_
      text = "hello world"
      text2 = "I have a pen."
      for out_type in [str, int, "serialized_proto", "immutable_proto"]:
          results = sp.sample_encode_and_score(
              text, wor=True, num_samples=10, out_type=out_type
          )
          results = sp.SampleEncodeAndScore(
              text, wor=False, num_samples=10, out_type=out_type
          )
  
          if out_type in [str, int]:
              for n in results:
                  self.assertEqual(sp.decode(n[0]), text)
  
          results = sp.sample_encode_and_score(
              [text, text2], wor=True, num_samples=10, out_type=out_type
          )
          results = sp.SampleEncodeAndScore(
              [text, text2], wor=True, num_samples=10, out_type=out_type
          )
  
          if out_type in [str, int]:
              for n in results[0]:
                  self.assertEqual(sp.decode(n[0]), text)
              for n in results[1]:
                  self.assertEqual(sp.decode(n[0]), text2)
  
      sp.sample_encode_and_score_as_pieces(text, 10)
      sp.sample_encode_and_score_as_ids(text, 10)
      sp.sample_encode_and_score_as_immutable_proto(text, 10)
      sp.sample_encode_and_score_as_serialized_proto(text, 10)
  
imports: from collections import defaultdict
  import io
  import os
  import pickle
  import sys
  import unittest
  import sentencepiece
label_desc: Use image node_id 15 for calling the TestSentencepieceProcessor obj's underlying member method code with example usage: obj.test_sample_and_score() without return types