

'''simple docstring'''






import os
import unittest

from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer
from transformers.testing_utils import require_jieba, tooslow

from ...test_tokenization_common import TokenizerTesterMixin






@require_jieba
class      lowercase_      (lowerCamelCase__							,			unittest.TestCase ):




  """simple docstring"""




  SCREAMING_SNAKE_CASE       :    Any							     =     CpmAntTokenizer
  SCREAMING_SNAKE_CASE       :    Dict							     =     False






  def    SCREAMING_SNAKE_CASE ( self  :	Optional[Any]     ):
   super().setUp()

   __lowercase				    =					[
       '''<d>''',
       '''</d>''',
       '''<s>''',
       '''</s>''',
       '''</_>''',
       '''<unk>''',
       '''<pad>''',
       '''</n>''',
       '''我''',
       '''是''',
       '''C''',
       '''P''',
       '''M''',
       '''A''',
       '''n''',
       '''t''',
   ]
   __lowercase				    =					os.path.join(self.tmpdirname   ,VOCAB_FILES_NAMES['''vocab_file''']     )
   with open(self.vocab_file   ,'''w'''   ,encoding='''utf-8'''     ) as vocab_writer:
    vocab_writer.write(''''''.join([x + '''\n''' for x in vocab_tokens]     )     )






  @tooslow
  def    SCREAMING_SNAKE_CASE ( self  :	Dict     ):
   __lowercase				    =					CpmAntTokenizer.from_pretrained('''openbmb/cpm-ant-10b'''     )
   __lowercase				    =					'''今天天气真好！'''
   __lowercase				    =					['''今天''', '''天气''', '''真''', '''好''', '''！''']
   __lowercase				    =					tokenizer.tokenize(lowercase__     )
   self.assertListEqual(lowercase__   ,lowercase__     )
   __lowercase				    =					'''今天天气真好！'''
   __lowercase				    =					[tokenizer.bos_token] + tokens

   __lowercase				    =					[6, 9_8_0_2, 1_4_9_6_2, 2_0_8_2, 8_3_1, 2_4_4]
   self.assertListEqual(tokenizer.convert_tokens_to_ids(lowercase__     )   ,lowercase__     )

   __lowercase				    =					tokenizer.decode(lowercase__     )
   self.assertEqual(lowercase__   ,lowercase__     )









'''simple docstring'''
from __future__ import annotations




def 		__SCREAMING_SNAKE_CASE       (	_UpperCamelCase				):


   """simple docstring"""




   lowercase_						:     Optional[int]							     =  2
   lowercase_						:     Tuple							     =  []
   while i * i <= n:
      if n % i:
         i += 1
      else:
         n //= i
         factors.append(_UpperCamelCase				)
   if n > 1:
      factors.append(_UpperCamelCase				)
   return factors


if __name__ == "__main__":
 import doctest

 doctest.testmod()




