






"""simple docstring"""



A__	:    Tuple			 = range(2, 20 + 1)
A__	:    Union[str, Any]			 = [10**k for k in range(ks[-1] + 1)]
A__	:    dict[int, dict[int, list[list[int]]]]			 = {}

def 			_snake_case    (					lowerCamelCase__     :   Optional[Any]    ,						lowerCamelCase__     :   Dict    ,						lowerCamelCase__     :   Optional[Any]    ,						lowerCamelCase__     :   int  )    ->     List[str]:
							lowerCamelCase_	:							str									=sum(a_i[j] for j in range(lowerCamelCase__    ,						len(lowerCamelCase__  )  )  )
							lowerCamelCase_	:							Optional[Any]									=sum(a_i[j] * base[j] for j in range(min(len(lowerCamelCase__  )    ,						lowerCamelCase__  )  )  )

							lowerCamelCase_							,						lowerCamelCase_	:							Tuple									=0, 0
							lowerCamelCase_	:							int									=n - i

							lowerCamelCase_	:							Optional[int]									=memo.get(lowerCamelCase__  )

							if sub_memo is not None:
														lowerCamelCase_	:							str									=sub_memo.get(lowerCamelCase__  )

														if jumps is not None and len(lowerCamelCase__  ) > 0:
																					# find and make the largest jump without going over
																					lowerCamelCase_	:							Tuple									=-1
																					for _k in range(len(lowerCamelCase__  ) - 1    ,						-1    ,						-1  ):
																												if jumps[_k][2] <= k and jumps[_k][1] <= max_dn:
																																			lowerCamelCase_	:							Optional[int]									=_k
																																			break

																					if max_jump >= 0:
																												lowerCamelCase_							,						lowerCamelCase_							,						lowerCamelCase_	:							int									=jumps[max_jump]
																												# since the difference between jumps is cached, add c
																												lowerCamelCase_	:							Optional[int]									=diff + c
																												for j in range(min(lowerCamelCase__    ,						len(lowerCamelCase__  )  )  ):
																																			lowerCamelCase_							,						lowerCamelCase_	:							Union[str, Any]									=divmod(lowerCamelCase__    ,						10  )
																												if new_c > 0:
																																			add(lowerCamelCase__    ,						lowerCamelCase__    ,						lowerCamelCase__  )

														else:
																					lowerCamelCase_	:							List[Any]									=[]
							else:
														lowerCamelCase_	:							List[str]									={c: []}
														lowerCamelCase_	:							List[str]									=sub_memo

							if dn >= max_dn or c + diff >= base[k]:
														return diff, dn

							if k > ks[0]:
														while True:
																					# keep doing smaller jumps
																					lowerCamelCase_							,						lowerCamelCase_	:							Union[str, Any]									=next_term(lowerCamelCase__    ,						k - 1    ,						i + dn    ,						lowerCamelCase__  )
																					diff += _diff
																					dn += terms_jumped

																					if dn >= max_dn or c + diff >= base[k]:
																												break
							else:
														# would be too small a jump, just compute sequential terms instead
														lowerCamelCase_							,						lowerCamelCase_	:							int									=compute(lowerCamelCase__    ,						lowerCamelCase__    ,						i + dn    ,						lowerCamelCase__  )
														diff += _diff
														dn += terms_jumped

							lowerCamelCase_	:							Union[str, Any]									=sub_memo[c]

							# keep jumps sorted by # of terms skipped
							lowerCamelCase_	:							int									=0
							while j < len(lowerCamelCase__  ):
														if jumps[j][1] > dn:
																					break
														j += 1

							# cache the jump for this value digitsum(b) and c
							sub_memo[c].insert(lowerCamelCase__    ,						(diff, dn, k)  )
							return (diff, dn)

def 			_snake_case    (					lowerCamelCase__     :   Optional[Any]    ,						lowerCamelCase__     :   Optional[int]    ,						lowerCamelCase__     :   str    ,						lowerCamelCase__     :   Optional[int]  )    ->     List[str]:
							if i >= n:
														return 0, i
							if k > len(lowerCamelCase__  ):
														a_i.extend([0 for _ in range(k - len(lowerCamelCase__  )  )]  )

							# note: a_i -> b * 10^k + c
							# ds_b -> digitsum(b)
							# ds_c -> digitsum(c)
							lowerCamelCase_	:							List[Any]									=i
							lowerCamelCase_							,						lowerCamelCase_							,						lowerCamelCase_	:							Optional[Any]									=0, 0, 0
							for j in range(len(lowerCamelCase__  )  ):
														if j >= k:
																					ds_b += a_i[j]
														else:
																					ds_c += a_i[j]

							while i < n:
														i += 1
														lowerCamelCase_	:							Any									=ds_c + ds_b
														diff += addend
														lowerCamelCase_	:							List[str]									=0
														for j in range(lowerCamelCase__  ):
																					lowerCamelCase_	:							str									=a_i[j] + addend
																					lowerCamelCase_							,						lowerCamelCase_	:							str									=divmod(lowerCamelCase__    ,						10  )

																					ds_c += a_i[j]

														if addend > 0:
																					break

							if addend > 0:
														add(lowerCamelCase__    ,						lowerCamelCase__    ,						lowerCamelCase__  )
							return diff, i - start_i

def 			_snake_case    (					lowerCamelCase__     :   Any    ,						lowerCamelCase__     :   List[Any]    ,						lowerCamelCase__     :   List[str]  )    ->     Any:
							for j in range(lowerCamelCase__    ,						len(lowerCamelCase__  )  ):
														lowerCamelCase_	:							Any									=digits[j] + addend
														if s >= 10:
																					lowerCamelCase_							,						lowerCamelCase_	:							str									=divmod(lowerCamelCase__    ,						10  )
																					lowerCamelCase_	:							List[str]									=addend // 10 + quotient
														else:
																					lowerCamelCase_	:							Dict									=s
																					lowerCamelCase_	:							Tuple									=addend // 10

														if addend == 0:
																					break

							while addend > 0:
														lowerCamelCase_							,						lowerCamelCase_	:							List[str]									=divmod(lowerCamelCase__    ,						10  )
														digits.append(lowerCamelCase__  )

def 			_snake_case    (					lowerCamelCase__     :   int = 10**15  )    ->     int:
							lowerCamelCase_	:							str									=[1]
							lowerCamelCase_	:							int									=1
							lowerCamelCase_	:							List[Any]									=0
							while True:
														lowerCamelCase_							,						lowerCamelCase_	:							Tuple									=next_term(lowerCamelCase__    ,						20    ,						i + dn    ,						lowerCamelCase__  )
														dn += terms_jumped
														if dn == n - i:
																					break

							lowerCamelCase_	:							List[str]									=0
							for j in range(len(lowerCamelCase__  )  ):
														a_n += digits[j] * 10**j
							return a_n


if __name__ == "__main__":
						print(f'{solution() = }')











"""simple docstring"""



import copy
import json
import os
import tempfile

from transformers import is_torch_available

from .test_configuration_utils import config_common_kwargs







class        lowercase__      (							snake_case__       ):


			def __init__(				self					:  Tuple       ,	snake_case__					:  Optional[int]       ,	snake_case__					:  int=None       ,	snake_case__					:  Union[str, Any]=True       ,	snake_case__					:  Optional[int]=None       ,	**snake_case__					:  Optional[int] ):
										lowerCamelCase_	:							Dict									=parent
										lowerCamelCase_	:							List[str]									=config_class
										lowerCamelCase_	:							Union[str, Any]									=has_text_modality
										lowerCamelCase_	:							Optional[int]									=kwargs
										lowerCamelCase_	:							List[str]									=common_properties


			def      UpperCAmelCase__						(				self					:  Optional[Any] ):
										lowerCamelCase_	:							List[str]									=self.config_class(**self.inputs_dict )
										lowerCamelCase_	:							Any									=(
										    ["hidden_size", "num_attention_heads", "num_hidden_layers"]
										    if self.common_properties is None
										    else self.common_properties
										)

										# Add common fields for text models
										if self.has_text_modality:
																	common_properties.extend(["vocab_size"] )

										# Test that config has the common properties as getters
										for prop in common_properties:
																	self.parent.assertTrue(hasattr(snake_case__       ,	snake_case__ )       ,	msg=F"""`{prop}` does not exist""" )

										# Test that config has the common properties as setter
										for idx, name in enumerate(snake_case__ ):
																	try:
																								setattr(snake_case__       ,	snake_case__       ,	snake_case__ )
																								self.parent.assertEqual(
																								    getattr(snake_case__       ,	snake_case__ )       ,	snake_case__       ,	msg=F"""`{name} value {idx} expected, but was {getattr(snake_case__       ,	snake_case__ )}""" )
																	except NotImplementedError:
																								# Some models might not be able to implement setters for common_properties
																								# In that case, a NotImplementedError is raised
																								pass

        # Test if config class can be called with Config(prop_name=..)
										for idx, name in enumerate(snake_case__ ):
																	try:
																								lowerCamelCase_	:							Dict									=self.config_class(**{name: idx} )
																								self.parent.assertEqual(
																								    getattr(snake_case__       ,	snake_case__ )       ,	snake_case__       ,	msg=F"""`{name} value {idx} expected, but was {getattr(snake_case__       ,	snake_case__ )}""" )
																	except NotImplementedError:
																								# Some models might not be able to implement setters for common_properties
																								# In that case, a NotImplementedError is raised
																								pass


			def      UpperCAmelCase__						(				self					:  Any ):
										lowerCamelCase_	:							Tuple									=self.config_class(**self.inputs_dict )
										lowerCamelCase_	:							Any									=json.loads(config.to_json_string() )
										for key, value in self.inputs_dict.items():
																	self.parent.assertEqual(obj[key]       ,	snake_case__ )


			def      UpperCAmelCase__						(				self					:  int ):
										lowerCamelCase_	:							Tuple									=self.config_class(**self.inputs_dict )

										with tempfile.TemporaryDirectory() as tmpdirname:
																	lowerCamelCase_	:							List[Any]									=os.path.join(snake_case__       ,	"config.json" )
																	config_first.to_json_file(snake_case__ )
																	lowerCamelCase_	:							Optional[int]									=self.config_class.from_json_file(snake_case__ )

										self.parent.assertEqual(config_second.to_dict()       ,	config_first.to_dict() )


			def      UpperCAmelCase__						(				self					:  Dict ):
										lowerCamelCase_	:							Dict									=self.config_class(**self.inputs_dict )

										with tempfile.TemporaryDirectory() as tmpdirname:
																	config_first.save_pretrained(snake_case__ )
																	lowerCamelCase_	:							Optional[int]									=self.config_class.from_pretrained(snake_case__ )

										self.parent.assertEqual(config_second.to_dict()       ,	config_first.to_dict() )


			def      UpperCAmelCase__						(				self					:  str ):
										lowerCamelCase_	:							Dict									=self.config_class(**self.inputs_dict )

										lowerCamelCase_	:							Dict									="test"
										with tempfile.TemporaryDirectory() as tmpdirname:
																	lowerCamelCase_	:							str									=os.path.join(snake_case__       ,	snake_case__ )
																	config_first.save_pretrained(snake_case__ )
																	lowerCamelCase_	:							Optional[Any]									=self.config_class.from_pretrained(snake_case__       ,	subfolder=snake_case__ )

										self.parent.assertEqual(config_second.to_dict()       ,	config_first.to_dict() )


			def      UpperCAmelCase__						(				self					:  Optional[Any] ):
										lowerCamelCase_	:							Optional[Any]									=self.config_class(**self.inputs_dict       ,	num_labels=5 )
										self.parent.assertEqual(len(config.idalabel )       ,	5 )
										self.parent.assertEqual(len(config.labelaid )       ,	5 )

										lowerCamelCase_	:							List[Any]									=3
										self.parent.assertEqual(len(config.idalabel )       ,	3 )
										self.parent.assertEqual(len(config.labelaid )       ,	3 )


			def      UpperCAmelCase__						(				self					:  List[Any] ):
										if self.config_class.is_composition:
																	return
										lowerCamelCase_	:							Tuple									=self.config_class()
										self.parent.assertIsNotNone(snake_case__ )


			def      UpperCAmelCase__						(				self					:  List[Any] ):
										lowerCamelCase_	:							List[str]									=copy.deepcopy(snake_case__ )
										lowerCamelCase_	:							Optional[int]									=self.config_class(**snake_case__ )
										lowerCamelCase_	:							Union[str, Any]									=[]
										for key, value in config_common_kwargs.items():
																	if key == "torch_dtype":
																								if not is_torch_available():
																															continue
																								else:
																															import torch

																															if config.torch_dtype != torch.floataa:
																																						wrong_values.append(("torch_dtype", config.torch_dtype, torch.floataa) )
																	elif getattr(snake_case__       ,	snake_case__ ) != value:
																								wrong_values.append((key, getattr(snake_case__       ,	snake_case__ ), value) )

										if len(snake_case__ ) > 0:
																	lowerCamelCase_	:							Any									="\n".join([F"""- {v[0]}: got {v[1]} instead of {v[2]}""" for v in wrong_values] )
																	raise ValueError(F"""The following keys were not properly set in the config:\n{errors}""" )


			def      UpperCAmelCase__						(				self					:  int ):
										self.create_and_test_config_common_properties()
										self.create_and_test_config_to_json_string()
										self.create_and_test_config_to_json_file()
										self.create_and_test_config_from_and_save_pretrained()
										self.create_and_test_config_from_and_save_pretrained_subfolder()
										self.create_and_test_config_with_num_labels()
										self.check_config_can_be_init_without_params()
										self.check_config_arguments_init()



