


'''simple docstring'''
import unittest
from dataclasses import dataclass
from typing import Optional

from transformers.utils import ModelOutput






@dataclass
class 				__lowerCAmelCase      (      lowercase	):

						"""simple docstring"""






						_UpperCAmelCase		:					float
						_UpperCAmelCase		:					Optional[float]      	=	None
						_UpperCAmelCase		:					Optional[float]      	=	None






class 				__lowerCAmelCase      (      unittest.TestCase	):

						"""simple docstring"""






						def 							_UpperCAmelCase					(     self       :			str  ):
													A_ 						=		ModelOutputTest(a=30  )
													self.assertEqual(x.a   ,     30  )
													self.assertIsNone(x.b  )
													self.assertIsNone(x.c  )
													with self.assertRaises(lowerCAmelCase  ):
																				A_ 						=		x.d






						def 							_UpperCAmelCase					(     self       :			Any  ):
													A_ 						=		ModelOutputTest(a=30   ,     b=10  )
													self.assertEqual(x[0]   ,     30  )
													self.assertEqual(x[1]   ,     10  )
													self.assertEqual(x[:2]   ,     (30, 10)  )
													self.assertEqual(x[:]   ,     (30, 10)  )

													A_ 						=		ModelOutputTest(a=30   ,     c=10  )
													self.assertEqual(x[0]   ,     30  )
													self.assertEqual(x[1]   ,     10  )
													self.assertEqual(x[:2]   ,     (30, 10)  )
													self.assertEqual(x[:]   ,     (30, 10)  )






						def 							_UpperCAmelCase					(     self       :			List[Any]  ):
													A_ 						=		ModelOutputTest(a=30   ,     b=10  )
													self.assertEqual(x["a"]   ,     30  )
													self.assertEqual(x["b"]   ,     10  )
													with self.assertRaises(lowerCAmelCase  ):
																				A_ 						=		x["c"]

													A_ 						=		ModelOutputTest(a=30   ,     c=10  )
													self.assertEqual(x["a"]   ,     30  )
													self.assertEqual(x["c"]   ,     10  )
													with self.assertRaises(lowerCAmelCase  ):
																				A_ 						=		x["b"]






						def 							_UpperCAmelCase					(     self       :			List[Any]  ):
													A_ 						=		ModelOutputTest(a=30  )
													self.assertEqual(list(x.keys()  )   ,     ["a"]  )
													self.assertEqual(list(x.values()  )   ,     [30]  )
													self.assertEqual(list(x.items()  )   ,     [("a", 30)]  )
													self.assertEqual(list(lowerCAmelCase  )   ,     ["a"]  )

													A_ 						=		ModelOutputTest(a=30   ,     b=10  )
													self.assertEqual(list(x.keys()  )   ,     ["a", "b"]  )
													self.assertEqual(list(x.values()  )   ,     [30, 10]  )
													self.assertEqual(list(x.items()  )   ,     [("a", 30), ("b", 10)]  )
													self.assertEqual(list(lowerCAmelCase  )   ,     ["a", "b"]  )

													A_ 						=		ModelOutputTest(a=30   ,     c=10  )
													self.assertEqual(list(x.keys()  )   ,     ["a", "c"]  )
													self.assertEqual(list(x.values()  )   ,     [30, 10]  )
													self.assertEqual(list(x.items()  )   ,     [("a", 30), ("c", 10)]  )
													self.assertEqual(list(lowerCAmelCase  )   ,     ["a", "c"]  )

													with self.assertRaises(lowerCAmelCase  ):
																				A_ 						=		x.update({"d": 20}  )
													with self.assertRaises(lowerCAmelCase  ):
																				del x["a"]
													with self.assertRaises(lowerCAmelCase  ):
																				A_ 						=		x.pop("a"  )
													with self.assertRaises(lowerCAmelCase  ):
																				A_ 						=		x.setdefault("d"   ,     32  )






						def 							_UpperCAmelCase					(     self       :			Optional[int]  ):
													A_ 						=		ModelOutputTest(a=30  )
													A_ 						=		10
													self.assertEqual(x.a   ,     10  )
													self.assertEqual(x["a"]   ,     10  )






						def 							_UpperCAmelCase					(     self       :			List[Any]  ):
													A_ 						=		ModelOutputTest(a=30  )
													A_ 						=		10
													self.assertEqual(x.a   ,     10  )
													self.assertEqual(x["a"]   ,     10  )






						def 							_UpperCAmelCase					(     self       :			Any  ):
													A_ 						=		ModelOutputTest({"a": 30, "b": 10}  )
													self.assertEqual(list(x.keys()  )   ,     ["a", "b"]  )
													self.assertEqual(x.a   ,     30  )
													self.assertEqual(x.b   ,     10  )






						def 							_UpperCAmelCase					(     self       :			List[str]  ):
													A_ 						=		ModelOutputTest([("a", 30), ("b", 10)]  )
													self.assertEqual(list(x.keys()  )   ,     ["a", "b"]  )
													self.assertEqual(x.a   ,     30  )
													self.assertEqual(x.b   ,     10  )

													with self.assertRaises(lowerCAmelCase  ):
																				A_ 						=		ModelOutputTest([("a", 30), (10, 10)]  )

													A_ 						=		ModelOutputTest(a=(30, 30)  )
													self.assertEqual(list(x.keys()  )   ,     ["a"]  )
													self.assertEqual(x.a   ,     (30, 30)  )









'''simple docstring'''
def 			a_							(  UpperCamelCase_	,     UpperCamelCase_ = 1_0_0_0   ):
							if (not isinstance(UpperCamelCase_	,     UpperCamelCase_   )) or (digit_position <= 0):
														raise ValueError("Digit position must be a positive integer"   )
							elif (not isinstance(UpperCamelCase_	,     UpperCamelCase_   )) or (precision < 0):
														raise ValueError("Precision must be a nonnegative integer"   )

							# compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
							# accurate
							A_ 						=		(
							    4 * _subsum(UpperCamelCase_	,     1	,     UpperCamelCase_   )
							    - 2 * _subsum(UpperCamelCase_	,     4	,     UpperCamelCase_   )
							    - _subsum(UpperCamelCase_	,     5	,     UpperCamelCase_   )
							    - _subsum(UpperCamelCase_	,     6	,     UpperCamelCase_   )
							)

							# return the first hex digit of the fractional part of the result
							return hex(int((sum_result % 1) * 1_6   )   )[2:]







def 			a_							(  UpperCamelCase_	,     UpperCamelCase_	,     UpperCamelCase_   ):
							A_ 						=		0.0
							for sum_index in range(digit_pos_to_extract + precision   ):
														A_ 						=		8 * sum_index + denominator_addend
														if sum_index < digit_pos_to_extract:
																					# if the exponential term is an integer and we mod it by the denominator
																					# before dividing, only the integer part of the sum will change;
																					# the fractional part will not
																					A_ 						=		pow(
																					    1_6	,     digit_pos_to_extract - 1 - sum_index	,     UpperCamelCase_   )
														else:
																					A_ 						=		pow(1_6	,     digit_pos_to_extract - 1 - sum_index   )
														total += exponential_term / denominator
							return total


if __name__ == "__main__":
							import doctest

							doctest.testmod()





