


'''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 						a__							(				a__							,							unittest.TestCase    ):





							'''simple docstring'''






							lowercase__     :  List[Any]      		= CpmAntTokenizer
							lowercase__     :  Any      		= False







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				List[Any]:
														super().setUp()

														lowerCAmelCase__			  =      [
														    '''<d>''',
														    '''</d>''',
														    '''<s>''',
														    '''</s>''',
														    '''</_>''',
														    '''<unk>''',
														    '''<pad>''',
														    '''</n>''',
														    '''我''',
														    '''是''',
														    '''C''',
														    '''P''',
														    '''M''',
														    '''A''',
														    '''n''',
														    '''t''',
														]
														lowerCAmelCase__			  =      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:
														lowerCAmelCase__			  =      CpmAntTokenizer.from_pretrained('''openbmb/cpm-ant-10b'''  )
														lowerCAmelCase__			  =      '''今天天气真好！'''
														lowerCAmelCase__			  =      ['''今天''', '''天气''', '''真''', '''好''', '''！''']
														lowerCAmelCase__			  =      tokenizer.tokenize(lowerCamelCase_  )
														self.assertListEqual(lowerCamelCase_   ,       lowerCamelCase_  )
														lowerCAmelCase__			  =      '''今天天气真好！'''
														lowerCAmelCase__			  =      [tokenizer.bos_token] + tokens

														lowerCAmelCase__			  =      [6, 98_02, 1_49_62, 20_82, 8_31, 2_44]
														self.assertListEqual(tokenizer.convert_tokens_to_ids(lowerCamelCase_  )   ,       lowerCamelCase_  )

														lowerCAmelCase__			  =      tokenizer.decode(lowerCamelCase_  )
														self.assertEqual(lowerCamelCase_   ,       lowerCamelCase_  )







"""simple docstring"""





_SCREAMING_SNAKE_CASE   :							Optional[int]          =		8.314_4598







def 	lowerCamelCase__			(				_lowerCamelCase			:						float						,							_lowerCamelCase			:						float					) ->							float:
  if temperature < 0:
    raise Exception('Temperature cannot be less than 0 K'					)
  if molar_mass <= 0:
    raise Exception('Molar mass cannot be less than or equal to 0 kg/mol'					)
  else:
    return (3 * UNIVERSAL_GAS_CONSTANT * temperature / molar_mass) ** 0.5


if __name__ == "__main__":
  import doctest

  # run doctest
  doctest.testmod()

  # example
  _SCREAMING_SNAKE_CASE   :							List[Any]          =		300
  _SCREAMING_SNAKE_CASE   :							Dict          =		28
  _SCREAMING_SNAKE_CASE   :							List[str]          =		rms_speed_of_molecule(temperature, molar_mass)
  print(F'''Vrms of Nitrogen gas at 300 K is {vrms} m/s''')




