





"""simple docstring"""




import json
import os
import unittest

from transformers import DebertaTokenizer, DebertaTokenizerFast
from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES
from transformers.testing_utils import slow

from ...test_tokenization_common import TokenizerTesterMixin


class        __UpperCamelCase				(						a__		,       unittest.TestCase						):
							lowerCamelCase   :					Dict      					=DebertaTokenizer
							lowerCamelCase   :					Optional[Any]      					=True
							lowerCamelCase   :					List[Any]      					=DebertaTokenizerFast






							def     __a   (   self      )	-> Optional[int]:
								super().setUp()

								# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
								a      :		Optional[int]	=				[
								    "l",
								    "o",
								    "w",
								    "e",
								    "r",
								    "s",
								    "t",
								    "i",
								    "d",
								    "n",
								    "\u0120",
								    "\u0120l",
								    "\u0120n",
								    "\u0120lo",
								    "\u0120low",
								    "er",
								    "\u0120lowest",
								    "\u0120newer",
								    "\u0120wider",
								    "[UNK]",
								]
								a      :		str	=				dict(zip(lowerCAmelCase__      ,					range(len(lowerCAmelCase__      )      )      )      )
								a      :		str	=				["#version: 0.2", "\u0120 l", "\u0120l o", "\u0120lo w", "e r", ""]
								a      :		Dict	=				{"unk_token": "[UNK]"}

								a      :		Union[str, Any]	=				os.path.join(self.tmpdirname      ,					VOCAB_FILES_NAMES["vocab_file"]      )
								a      :		str	=				os.path.join(self.tmpdirname      ,					VOCAB_FILES_NAMES["merges_file"]      )
								with open(self.vocab_file      ,					"w"      ,					encoding="utf-8"      ) as fp:
									fp.write(json.dumps(lowerCAmelCase__      ) + "\n"      )
								with open(self.merges_file      ,					"w"      ,					encoding="utf-8"      ) as fp:
									fp.write("\n".join(lowerCAmelCase__      )      )






							def     __a   (   self      ,					**lowerCAmelCase__      )	-> str:
								kwargs.update(self.special_tokens_map      )
								return self.tokenizer_class.from_pretrained(self.tmpdirname      ,					**lowerCAmelCase__      )






							def     __a   (   self      ,					lowerCAmelCase__      )	-> List[Any]:
								a      :		Dict	=				"lower newer"
								a      :		Dict	=				"lower newer"
								return input_text, output_text






							def     __a   (   self      )	-> List[Any]:
								a      :		str	=				self.get_tokenizer()
								a      :		str	=				"lower newer"
								a      :		Union[str, Any]	=				["l", "o", "w", "er", "\u0120", "n", "e", "w", "er"]
								a      :		Optional[int]	=				tokenizer.tokenize(lowerCAmelCase__      )
								self.assertListEqual(lowerCAmelCase__      ,					lowerCAmelCase__      )

								a      :		Tuple	=				tokens + [tokenizer.unk_token]
								a      :		Union[str, Any]	=				[0, 1, 2, 15, 10, 9, 3, 2, 15, 19]
								self.assertListEqual(tokenizer.convert_tokens_to_ids(lowerCAmelCase__      )      ,					lowerCAmelCase__      )






							def     __a   (   self      )	-> List[Any]:
								a      :		List[Any]	=				self.get_tokenizer()
								a      :		Optional[Any]	=				tokenizer("Hello"      ,					"World"      )
								a      :		List[Any]	=				[0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]
								self.assertListEqual(tokd["token_type_ids"]      ,					lowerCAmelCase__      )






							@slow
							def     __a   (   self      )	-> Tuple:
								a      :		Tuple	=				self.tokenizer_class.from_pretrained("microsoft/deberta-base"      )

								a      :		Dict	=				tokenizer.encode("sequence builders"      ,					add_special_tokens=lowerCAmelCase__      )
								a      :		str	=				tokenizer.encode("multi-sequence build"      ,					add_special_tokens=lowerCAmelCase__      )

								a      :		Dict	=				tokenizer.encode(
								    "sequence builders"      ,					add_special_tokens=lowerCAmelCase__      ,					add_prefix_space=lowerCAmelCase__      )
								a      :		Optional[int]	=				tokenizer.encode(
								    "sequence builders"      ,					"multi-sequence build"      ,					add_special_tokens=lowerCAmelCase__      ,					add_prefix_space=lowerCAmelCase__      )

								a      :		str	=				tokenizer.build_inputs_with_special_tokens(lowerCAmelCase__      )
								a      :		List[str]	=				tokenizer.build_inputs_with_special_tokens(lowerCAmelCase__      ,					lowerCAmelCase__      )

								assert encoded_sentence == encoded_text_from_decode
								assert encoded_pair == encoded_pair_from_decode






							@slow
							def     __a   (   self      )	-> str:
								a      :		str	=				[self.tokenizer_class]
								if self.test_rust_tokenizer:
									tokenizer_classes.append(self.rust_tokenizer_class      )

								for tokenizer_class in tokenizer_classes:
									a      :		int	=				tokenizer_class.from_pretrained("microsoft/deberta-base"      )

									a      :		Optional[int]	=				[
									    "ALBERT: A Lite BERT for Self-supervised Learning of Language Representations",
									    "ALBERT incorporates two parameter reduction techniques",
									    "The first one is a factorized embedding parameterization. By decomposing the large vocabulary"
									    " embedding matrix into two small matrices, we separate the size of the hidden layers from the size of"
									    " vocabulary embedding.",
									]

									a      :		Dict	=				tokenizer(lowerCAmelCase__      ,					padding=lowerCAmelCase__      )
									a      :		Optional[Any]	=				[tokenizer.decode(lowerCAmelCase__      ,					skip_special_tokens=lowerCAmelCase__      ) for seq in encoding["input_ids"]]

									# fmt: off
									a      :		Optional[int]	=				{
									    "input_ids": [
									        [1, 2118, 1_1126, 565, 35, 83, 2_5191, 163, 1_8854, 13, 1_2156, 12, 1_6101, 2_5376, 1_3807, 9, 2_2205, 2_7893, 1635, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
									        [1, 2118, 1_1126, 565, 2_4536, 80, 4_3797, 4878, 7373, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
									        [1, 133, 78, 65, 16, 10, 3724, 1538, 3_3183, 1_1303, 4_3797, 1938, 4, 870, 2_4165, 2_9105, 5, 739, 3_2644, 3_3183, 1_1303, 3_6173, 88, 80, 650, 7821, 4_5940, 6, 52, 2559, 5, 1836, 9, 5, 7397, 1_3171, 31, 5, 1836, 9, 3_2644, 3_3183, 1_1303, 4, 2]
									    ],
									    "token_type_ids": [
									        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
									        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
									        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
									    ],
									    "attention_mask": [
									        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
									        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
									        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
									    ]
									}
									# fmt: on

									a      :		Union[str, Any]	=				[
									    "ALBERT: A Lite BERT for Self-supervised Learning of Language Representations",
									    "ALBERT incorporates two parameter reduction techniques",
									    "The first one is a factorized embedding parameterization. By decomposing the large vocabulary"
									    " embedding matrix into two small matrices, we separate the size of the hidden layers from the size of"
									    " vocabulary embedding.",
									]

									self.assertDictEqual(encoding.data      ,					lowerCAmelCase__      )

									for expected, decoded in zip(lowerCAmelCase__      ,					lowerCAmelCase__      ):
										self.assertEqual(lowerCAmelCase__      ,					lowerCAmelCase__      )








from math import pi, sqrt, tan







def 			lowerCamelCase_		(       UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if side_length < 0:
								raise ValueError('surface_area_cube() only accepts non-negative values'      )
				return 6 * side_length**2







def 			lowerCamelCase_		(       UpperCamelCase__				:      float ,     UpperCamelCase__				:      float ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if length < 0 or breadth < 0 or height < 0:
								raise ValueError('surface_area_cuboid() only accepts non-negative values'      )
				return 2 * ((length * breadth) + (breadth * height) + (length * height))







def 			lowerCamelCase_		(       UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if radius < 0:
								raise ValueError('surface_area_sphere() only accepts non-negative values'      )
				return 4 * pi * radius**2







def 			lowerCamelCase_		(       UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if radius < 0:
								raise ValueError('surface_area_hemisphere() only accepts non-negative values'      )
				return 3 * pi * radius**2







def 			lowerCamelCase_		(       UpperCamelCase__				:      float ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if radius < 0 or height < 0:
								raise ValueError('surface_area_cone() only accepts non-negative values'      )
				return pi * radius * (radius + (height**2 + radius**2) ** 0.5)







def 			lowerCamelCase_		(       UpperCamelCase__				:      float ,     UpperCamelCase__				:      float ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if radius_a < 0 or radius_a < 0 or height < 0:
								raise ValueError(
								    'surface_area_conical_frustum() only accepts non-negative values'      )
				__lowerCamelCase		       =    (height**2 + (radius_a - radius_a) ** 2) ** 0.5
				return pi * ((slant_height * (radius_a + radius_a)) + radius_a**2 + radius_a**2)







def 			lowerCamelCase_		(       UpperCamelCase__				:      float ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if radius < 0 or height < 0:
								raise ValueError('surface_area_cylinder() only accepts non-negative values'      )
				return 2 * pi * radius * (height + radius)







def 			lowerCamelCase_		(       UpperCamelCase__				:      float ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if torus_radius < 0 or tube_radius < 0:
								raise ValueError('surface_area_torus() only accepts non-negative values'      )
				if torus_radius < tube_radius:
								raise ValueError(
								    'surface_area_torus() does not support spindle or self intersecting tori'      )
				return 4 * pow(UpperCamelCase__ ,     2      ) * torus_radius * tube_radius







def 			lowerCamelCase_		(       UpperCamelCase__				:      float ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if length < 0 or width < 0:
								raise ValueError('area_rectangle() only accepts non-negative values'      )
				return length * width







def 			lowerCamelCase_		(       UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if side_length < 0:
								raise ValueError('area_square() only accepts non-negative values'      )
				return side_length**2







def 			lowerCamelCase_		(       UpperCamelCase__				:      float ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if base < 0 or height < 0:
								raise ValueError('area_triangle() only accepts non-negative values'      )
				return (base * height) / 2







def 			lowerCamelCase_		(       UpperCamelCase__				:      float ,     UpperCamelCase__				:      float ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if sidea < 0 or sidea < 0 or sidea < 0:
								raise ValueError('area_triangle_three_sides() only accepts non-negative values'      )
				elif sidea + sidea < sidea or sidea + sidea < sidea or sidea + sidea < sidea:
								raise ValueError('Given three sides do not form a triangle'      )
				__lowerCamelCase		       =    (sidea + sidea + sidea) / 2
				__lowerCamelCase		       =    sqrt(
				    semi_perimeter
				    * (semi_perimeter - sidea)
				    * (semi_perimeter - sidea)
				    * (semi_perimeter - sidea)      )
				return area







def 			lowerCamelCase_		(       UpperCamelCase__				:      float ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if base < 0 or height < 0:
								raise ValueError('area_parallelogram() only accepts non-negative values'      )
				return base * height







def 			lowerCamelCase_		(       UpperCamelCase__				:      float ,     UpperCamelCase__				:      float ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if basea < 0 or basea < 0 or height < 0:
								raise ValueError('area_trapezium() only accepts non-negative values'      )
				return 1 / 2 * (basea + basea) * height







def 			lowerCamelCase_		(       UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if radius < 0:
								raise ValueError('area_circle() only accepts non-negative values'      )
				return pi * radius**2







def 			lowerCamelCase_		(       UpperCamelCase__				:      float ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if radius_x < 0 or radius_y < 0:
								raise ValueError('area_ellipse() only accepts non-negative values'      )
				return pi * radius_x * radius_y







def 			lowerCamelCase_		(       UpperCamelCase__				:      float ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if diagonal_a < 0 or diagonal_a < 0:
								raise ValueError('area_rhombus() only accepts non-negative values'      )
				return 1 / 2 * diagonal_a * diagonal_a







def 			lowerCamelCase_		(       UpperCamelCase__				:      int ,     UpperCamelCase__				:      float      )     ->       float:





				"""simple docstring"""


				if not isinstance(UpperCamelCase__ ,     UpperCamelCase__      ) or sides < 3:
								raise ValueError(
								    'area_reg_polygon() only accepts integers greater than or \
equal to three as number of sides'      )
				elif length < 0:
								raise ValueError(
								    'area_reg_polygon() only accepts non-negative values as \
length of a side'      )
				return (sides * length**2) / (4 * tan(pi / sides      ))
				return (sides * length**2) / (4 * tan(pi / sides      ))


if __name__ == "__main__":
					import doctest

					doctest.testmod(verbose=True)  # verbose so we can see methods missing tests

					print("[DEMO] Areas of various geometric shapes: \n")
					print(f'''Rectangle: {area_rectangle(10, 20) = }''')
					print(f'''Square: {area_square(10) = }''')
					print(f'''Triangle: {area_triangle(10, 10) = }''')
					print(f'''Triangle: {area_triangle_three_sides(5, 12, 13) = }''')
					print(f'''Parallelogram: {area_parallelogram(10, 20) = }''')
					print(f'''Rhombus: {area_rhombus(10, 20) = }''')
					print(f'''Trapezium: {area_trapezium(10, 20, 30) = }''')
					print(f'''Circle: {area_circle(20) = }''')
					print(f'''Ellipse: {area_ellipse(10, 20) = }''')
					print("\nSurface Areas of various geometric shapes: \n")
					print(f'''Cube: {surface_area_cube(20) = }''')
					print(f'''Cuboid: {surface_area_cuboid(10, 20, 30) = }''')
					print(f'''Sphere: {surface_area_sphere(20) = }''')
					print(f'''Hemisphere: {surface_area_hemisphere(20) = }''')
					print(f'''Cone: {surface_area_cone(10, 20) = }''')
					print(f'''Conical Frustum: {surface_area_conical_frustum(10, 20, 30) = }''')
					print(f'''Cylinder: {surface_area_cylinder(10, 20) = }''')
					print(f'''Torus: {surface_area_torus(20, 10) = }''')
					print(f'''Equilateral Triangle: {area_reg_polygon(3, 10) = }''')
					print(f'''Square: {area_reg_polygon(4, 10) = }''')
					print(f'''Reqular Pentagon: {area_reg_polygon(5, 10) = }''')


