






import json
import os
import unittest

from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import (
    VOCAB_FILES_NAMES,
    GPTSanJapaneseTokenizer,
)
from transformers.testing_utils import require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


@require_tokenizers
class       __lowercase      (	__a			,      unittest.TestCase  ):







     '''simple docstring'''
     SCREAMING_SNAKE_CASE   						=				GPTSanJapaneseTokenizer
     SCREAMING_SNAKE_CASE   						=				False
     SCREAMING_SNAKE_CASE   						=				{"do_clean_text": False, "add_prefix_space": False}




     def 		lowerCAmelCase_     (				self       :			Dict				):


         """simple docstring"""



         super().setUp()

         # fmt: off
         __A         =	["""こん""", """こんに""", """にちは""", """ばんは""", """世界,㔺界""", """、""", """。""", """<BR>""", """<SP>""", """<TAB>""", """<URL>""", """<EMAIL>""", """<TEL>""", """<DATE>""", """<PRICE>""", """<BLOCK>""", """<KIGOU>""", """<U2000U2BFF>""", """<|emoji1|>""", """<unk>""", """<|bagoftoken|>""", """<|endoftext|>"""]
         # fmt: on
         __A         =	{"""emoji""": {"""\ud83d\ude00""": """<|emoji1|>"""}, """emoji_inv""": {"""<|emoji1|>""": """\ud83d\ude00"""}}  # 😀
         __A         =	{"""unk_token""": """<unk>"""}

         __A         =	os.path.join(self.tmpdirname ,	VOCAB_FILES_NAMES["""vocab_file"""]				)
         __A         =	os.path.join(self.tmpdirname ,	VOCAB_FILES_NAMES["""emoji_file"""]				)
         with open(self.vocab_file ,	"""w""" ,	encoding="""utf-8"""				) as vocab_writer:
             vocab_writer.write("""""".join([x + """\n""" for x in vocab_tokens]				)				)
         with open(self.emoji_file ,	"""w"""				) as emoji_writer:
             emoji_writer.write(json.dumps(a_				)				)




     def 		lowerCAmelCase_     (				self       :			Dict ,	**UpperCamelCase_       :			List[Any]				):


         """simple docstring"""



         kwargs.update(self.special_tokens_map				)
         return GPTSanJapaneseTokenizer.from_pretrained(self.tmpdirname ,	**a_				)




     def 		lowerCAmelCase_     (				self       :			int ,	UpperCamelCase_       :			Any				):


         """simple docstring"""



         __A         =	"""こんにちは、世界。 \nこんばんは、㔺界。😀"""
         __A         =	"""こんにちは、世界。 \nこんばんは、世界。😀"""
         return input_text, output_text




     def 		lowerCAmelCase_     (				self       :			Any ,	UpperCamelCase_       :			Optional[Any]				):


         """simple docstring"""



         __A         =	self.get_input_output_texts(a_				)
         __A         =	tokenizer.encode(a_ ,	add_special_tokens=a_				)
         __A         =	tokenizer.decode(a_ ,	clean_up_tokenization_spaces=a_				)
         return text, ids




     def 		lowerCAmelCase_     (				self       :			Union[str, Any]				):


         """simple docstring"""



         pass  # TODO add if relevant




     def 		lowerCAmelCase_     (				self       :			List[str]				):


         """simple docstring"""



         pass  # TODO add if relevant




     def 		lowerCAmelCase_     (				self       :			str				):


         """simple docstring"""



         pass  # TODO add if relevant




     def 		lowerCAmelCase_     (				self       :			int				):


         """simple docstring"""



         __A         =	self.get_tokenizer()

         # Testing tokenization
         __A         =	"""こんにちは、世界。　こんばんは、㔺界。"""
         __A         =	["""こん""", """にちは""", """、""", """世界""", """。""", """<SP>""", """こん""", """ばんは""", """、""", """㔺界""", """。"""]
         __A         =	tokenizer.tokenize(a_				)
         self.assertListEqual(a_ ,	a_				)

         # Testing conversion to ids without special tokens
         __A         =	[0, 2, 5, 4, 6, 8, 0, 3, 5, 4, 6]
         __A         =	tokenizer.convert_tokens_to_ids(a_				)
         self.assertListEqual(a_ ,	a_				)

         # Testing conversion to ids with special tokens
         __A         =	tokens + [tokenizer.unk_token]
         __A         =	[0, 2, 5, 4, 6, 8, 0, 3, 5, 4, 6, 19]
         __A         =	tokenizer.convert_tokens_to_ids(a_				)
         self.assertListEqual(a_ ,	a_				)




     def 		lowerCAmelCase_     (				self       :			str				):


         """simple docstring"""



         __A         =	self.get_tokenizer()

         # Testing tokenization
         __A         =	"""こんにちは、<|bagoftoken|>世界。こんばんは、<|bagoftoken|>㔺界。"""
         __A         =	"""こんにちは、、、、世界。こんばんは、、、、世界。"""
         __A         =	tokenizer.encode(a_				)
         __A         =	tokenizer.decode(a_				)
         self.assertEqual(a_ ,	a_				)




     @slow
     def 		lowerCAmelCase_     (				self       :			Union[str, Any]				):


         """simple docstring"""



         __A         =	self.tokenizer_class.from_pretrained("""Tanrei/GPTSAN-japanese"""				)

         # Testing tokenization
         __A         =	"""こんにちは、世界。"""
         __A         =	"""こんばんは、㔺界。😀"""
         __A         =	"""こんにちは、世界。こんばんは、世界。😀"""
         __A         =	tokenizer.encode(prefix_text + input_text				)
         __A         =	tokenizer.encode("""""" ,	prefix_text=prefix_text + input_text				)
         __A         =	tokenizer.encode(a_ ,	prefix_text=a_				)
         __A         =	tokenizer.decode(a_				)
         __A         =	tokenizer.decode(a_				)
         __A         =	tokenizer.decode(a_				)
         self.assertEqual(a_ ,	a_				)
         self.assertEqual(a_ ,	a_				)
         self.assertEqual(a_ ,	a_				)




     @slow
     def 		lowerCAmelCase_     (				self       :			Union[str, Any]				):


         """simple docstring"""



         __A         =	self.tokenizer_class.from_pretrained("""Tanrei/GPTSAN-japanese"""				)

         # Testing tokenization
         __A         =	"""こんにちは、世界。"""
         __A         =	"""こんばんは、㔺界。😀"""

         __A         =	len(tokenizer.encode(a_				)				) - 2
         __A         =	len(tokenizer.encode(a_				)				) - 2

         __A         =	[1] + [0] * (len_prefix + len_text + 1)
         __A         =	[1] * (len_prefix + len_text + 1) + [0]
         __A         =	[1] + [1] * (len_prefix) + [0] * (len_text + 1)

         __A         =	tokenizer(prefix_text + input_text				).token_type_ids
         __A         =	tokenizer("""""" ,	prefix_text=prefix_text + input_text				).token_type_ids
         __A         =	tokenizer(a_ ,	prefix_text=a_				).token_type_ids
         self.assertListEqual(a_ ,	a_				)
         self.assertListEqual(a_ ,	a_				)
         self.assertListEqual(a_ ,	a_				)




     @slow
     def 		lowerCAmelCase_     (				self       :			Dict				):


         """simple docstring"""



         __A         =	self.tokenizer_class.from_pretrained("""Tanrei/GPTSAN-japanese"""				)

         __A         =	tokenizer.encode("""あンいワ"""				)
         __A         =	tokenizer.encode("""""" ,	prefix_text="""あンいワ"""				)
         __A         =	tokenizer.encode("""いワ""" ,	prefix_text="""あン"""				)

         self.assertEqual(tokenizer.decode(a_				) ,	tokenizer.decode(a_				)				)
         self.assertEqual(tokenizer.decode(a_				) ,	tokenizer.decode(a_				)				)
         self.assertNotEqual(a_ ,	a_				)
         self.assertNotEqual(a_ ,	a_				)
         self.assertEqual(x_token_a[1] ,	x_token_a[-1]				)  # SEG token
         self.assertEqual(x_token_a[1] ,	x_token_a[3]				)  # SEG token




     @slow
     def 		lowerCAmelCase_     (				self       :			Optional[int]				):


         """simple docstring"""



         __A         =	self.tokenizer_class.from_pretrained("""Tanrei/GPTSAN-japanese"""				)

         __A         =	[["""武田信玄""", """は、"""], ["""織田信長""", """の配下の、"""]]
         __A         =	tokenizer(a_ ,	padding=a_				)
         __A         =	tokenizer.batch_encode_plus(a_ ,	padding=a_				)

         # fmt: off
         __A         =	[[35_993, 8_640, 25_948, 35_998, 30_647, 35_675, 35_999, 35_999], [35_993, 10_382, 9_868, 35_998, 30_646, 9_459, 30_646, 35_675]]
         __A         =	[[1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0]]
         __A         =	[[1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]]
         # fmt: on
         self.assertListEqual(x_token.input_ids ,	a_				)
         self.assertListEqual(x_token.token_type_ids ,	a_				)
         self.assertListEqual(x_token.attention_mask ,	a_				)
         self.assertListEqual(x_token_a.input_ids ,	a_				)
         self.assertListEqual(x_token_a.token_type_ids ,	a_				)
         self.assertListEqual(x_token_a.attention_mask ,	a_				)




     def 		lowerCAmelCase_     (				self       :			Dict				):


         """simple docstring"""



         pass





     def 		lowerCAmelCase_     (				self       :			Any				):


         """simple docstring"""



         pass














__a      :       List[Any]				  =   8.3_1_4_4_5_9_8



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			float			,				__lowercase   :			float    )						->      float:





    """simple docstring"""

    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
  __a      :       int				  =   300
  __a      :       int				  =   28
  __a      :       int				  =   rms_speed_of_molecule(temperature, molar_mass)
  print(f"""Vrms of Nitrogen gas at 300 K is {vrms} m/s""")




