class_docstr: Test case for SentencePieceProcessor
class_docstr_tok: ["Test","case","for","SentencePieceProcessor"]
code: def test_ja_roundtrip(self):
      text = "清水寺は京都にある。"
      ids = self.jasp_.EncodeAsIds(text)
      pieces1 = self.jasp_.EncodeAsPieces(text)
      pieces2 = self.jasp_.NBestEncodeAsPieces(text, 10)[0]
      self.assertEqual(pieces1, pieces2)
      self.assertEqual(text, self.jasp_.DecodePieces(pieces1))
      self.assertEqual(text, self.jasp_.DecodeIds(ids))
      for n in range(100):
          self.assertEqual(
              text,
              self.jasp_.DecodePieces(
                  self.jasp_.SampleEncodeAsPieces(text, 64, 0.5)
              ),
          )
          self.assertEqual(
              text,
              self.jasp_.DecodePieces(
                  self.jasp_.SampleEncodeAsPieces(text, -1, 0.5)
              ),
          )
  
      ids2 = self.jasp_.encode_as_ids(text)
      pieces3 = self.jasp_.encode_as_pieces(text)
      pieces4 = self.jasp_.nbest_encode_as_pieces(text, 10)[0]
      self.assertEqual(pieces3, pieces4)
      self.assertEqual(pieces1, pieces3)
      self.assertEqual(ids, ids2)
      self.assertEqual(text, self.jasp_.decode_pieces(pieces1))
      self.assertEqual(text, self.jasp_.decode_ids(ids2))
      for n in range(100):
          self.assertEqual(
              text,
              self.jasp_.decode_pieces(
                  self.jasp_.sample_encode_as_pieces(text, 64, 0.5)
              ),
          )
          self.assertEqual(
              text,
              self.jasp_.decode_pieces(
                  self.jasp_.sample_encode_as_pieces(text, -1, 0.5)
              ),
          )
  
          self.assertEqual(
              self.jasp_.calculate_entropy(text, 0.1),
              self.jasp_.CalculateEntropy(text, 0.1),
          )
  
imports: from collections import defaultdict
  import io
  import os
  import pickle
  import sys
  import unittest
  import sentencepiece
label_desc: Use image node_id 5 for calling the TestSentencepieceProcessor obj's underlying member method code with example usage: obj.test_ja_roundtrip() without return types