


"""simple docstring"""
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, List, Mapping, Optional

from packaging import version


if TYPE_CHECKING:
				from ... import PreTrainedTokenizer, TensorType

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfigWithPast, PatchingSpec
from ...utils import is_torch_available, logging


__SCREAMING_SNAKE_CASE							:    List[Any]		=    logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE							:    List[Any]		=    {
    """bigscience/bloom""": """https://huggingface.co/bigscience/bloom/resolve/main/config.json""",
    """bigscience/bloom-560m""": """https://huggingface.co/bigscience/bloom-560m/blob/main/config.json""",
    """bigscience/bloom-1b1""": """https://huggingface.co/bigscience/bloom-1b1/blob/main/config.json""",
    """bigscience/bloom-1b7""": """https://huggingface.co/bigscience/bloom-1b7/blob/main/config.json""",
    """bigscience/bloom-3b""": """https://huggingface.co/bigscience/bloom-3b/blob/main/config.json""",
    """bigscience/bloom-7b1""": """https://huggingface.co/bigscience/bloom-7b1/blob/main/config.json""",
}





class      __A     (__UpperCAmelCase):





							'''simple docstring'''

							__lowercase:		str							      =    """bloom"""
							__lowercase:		List[Any]							      =    ["""past_key_values"""]
							__lowercase:		List[str]							      =    {
							    """num_hidden_layers""": """n_layer""",
							    """num_attention_heads""": """n_head""",
							}



							def __init__(				self							:      Dict		,       UpperCAmelCase_							:      Union[str, Any]=250_880		,       UpperCAmelCase_							:      int=64		,       UpperCAmelCase_							:      Tuple=2		,       UpperCAmelCase_							:      Optional[Any]=8		,       UpperCAmelCase_							:      Optional[Any]=1E-5		,       UpperCAmelCase_							:      Any=0.02		,       UpperCAmelCase_							:      int=True		,       UpperCAmelCase_							:      Optional[Any]=1		,       UpperCAmelCase_							:      str=2		,       UpperCAmelCase_							:      Optional[int]=False		,       UpperCAmelCase_							:      int=0.0		,       UpperCAmelCase_							:      List[str]=0.0		,       UpperCAmelCase_							:      Optional[Any]=1		,       UpperCAmelCase_							:      str=False		,       **UpperCAmelCase_							:      Tuple		,       )					->Union[str, Any]:



														"""simple docstring"""



														snake_case_           =		vocab_size
														# Backward compatibility with n_embed kwarg
														snake_case_           =		kwargs.pop("""n_embed"""		,       UpperCAmelCase_       )
														snake_case_           =		hidden_size if n_embed is None else n_embed
														snake_case_           =		n_layer
														snake_case_           =		n_head
														snake_case_           =		layer_norm_epsilon
														snake_case_           =		initializer_range
														snake_case_           =		use_cache
														snake_case_           =		pretraining_tp
														snake_case_           =		apply_residual_connection_post_layernorm
														snake_case_           =		hidden_dropout
														snake_case_           =		attention_dropout

														snake_case_           =		bos_token_id
														snake_case_           =		eos_token_id
														snake_case_           =		slow_but_exact

														super().__init__(bos_token_id=UpperCAmelCase_		,       eos_token_id=UpperCAmelCase_		,       **UpperCAmelCase_       )





class      __A     (__UpperCAmelCase):





							'''simple docstring'''

							__lowercase:		List[str]							      =    version.parse("""1.12""")



							def __init__(				self							:      Any		,       UpperCAmelCase_							:      Optional[Any]		,       UpperCAmelCase_							:      Any = "default"		,       UpperCAmelCase_							:      Any = None		,       UpperCAmelCase_							:      str = False		,       )					->List[Any]:



														"""simple docstring"""



														super().__init__(UpperCAmelCase_		,       task=UpperCAmelCase_		,       patching_specs=UpperCAmelCase_		,       use_past=UpperCAmelCase_       )
														if not getattr(self._config		,       """pad_token_id"""		,       UpperCAmelCase_       ):
																					# TODO: how to do that better?
																					snake_case_           =		0



							@property
							def 		lowerCAmelCase       (				self							:      Union[str, Any]       )					->Tuple:



														"""simple docstring"""



														snake_case_           =		OrderedDict({"""input_ids""": {0: """batch""", 1: """sequence"""}}       )
														if self.use_past:
																					# BLOOM stores values on dynamic axis 2. For more details see: https://github.com/huggingface/transformers/pull/18344
																					self.fill_with_past_key_values_(UpperCAmelCase_		,       direction="""inputs"""		,       inverted_values_shape=UpperCAmelCase_       )
																					snake_case_           =		{0: """batch""", 1: """past_sequence + sequence"""}
														else:
																					snake_case_           =		{0: """batch""", 1: """sequence"""}

														return common_inputs



							@property
							def 		lowerCAmelCase       (				self							:      Union[str, Any]       )					->Tuple:



														"""simple docstring"""



														return self._config.n_layer



							@property
							def 		lowerCAmelCase       (				self							:      Any       )					->Optional[int]:



														"""simple docstring"""



														return self._config.n_head



							@property
							def 		lowerCAmelCase       (				self							:      Union[str, Any]       )					->List[Any]:



														"""simple docstring"""



														return 1E-3



							def 		lowerCAmelCase       (				self							:      Any		,       UpperCAmelCase_							:      str		,       UpperCAmelCase_							:      Optional[int] = -1		,       UpperCAmelCase_							:      Any = -1		,       UpperCAmelCase_							:      List[str] = False		,       UpperCAmelCase_							:      Optional[int] = None		,       )					->List[Any]:



														"""simple docstring"""



														snake_case_           =		super(UpperCAmelCase_		,       self       ).generate_dummy_inputs(
														    UpperCAmelCase_		,       batch_size=UpperCAmelCase_		,       seq_length=UpperCAmelCase_		,       is_pair=UpperCAmelCase_		,       framework=UpperCAmelCase_       )

														# We need to order the input in the way they appears in the forward()
														snake_case_           =		OrderedDict({"""input_ids""": common_inputs["""input_ids"""]}       )

														# Need to add the past_keys
														if self.use_past:
																					if not is_torch_available():
																												raise ValueError("""Cannot generate dummy past_keys inputs without PyTorch installed."""       )
																					else:
																												import torch

																												snake_case_       ,						snake_case_           =		common_inputs["""input_ids"""].shape
																												# Not using the same length for past_key_values
																												snake_case_           =		seqlen + 2
																												snake_case_           =		self._config.hidden_size // self.num_attention_heads
																												snake_case_           =		(
																												    batch * self.num_attention_heads,
																												    head_dim,
																												    past_key_values_length,
																												)
																												snake_case_           =		(
																												    batch * self.num_attention_heads,
																												    past_key_values_length,
																												    head_dim,
																												)
																												snake_case_           =		[
																												    (torch.zeros(UpperCAmelCase_       ), torch.zeros(UpperCAmelCase_       )) for _ in range(self.num_layers       )
																												]

														snake_case_           =		common_inputs["""attention_mask"""]
														if self.use_past:
																					snake_case_           =		ordered_inputs["""attention_mask"""].dtype
																					snake_case_           =		torch.cat(
																					    [ordered_inputs["""attention_mask"""], torch.ones(UpperCAmelCase_		,       UpperCAmelCase_		,       dtype=UpperCAmelCase_       )]		,       dim=1       )

														return ordered_inputs



							@property
							def 		lowerCAmelCase       (				self							:      Optional[Any]       )					->Optional[int]:



														"""simple docstring"""



														return 13







"""simple docstring"""
__SCREAMING_SNAKE_CASE							:    str		=    'Input must be a string of 8 numbers plus letter'
__SCREAMING_SNAKE_CASE							:    Dict		=    'TRWAGMYFPDXBNJZSQVHLCKE'







def 						_a				(      _SCREAMING_SNAKE_CASE				)    ->				bool:

							if not isinstance(_SCREAMING_SNAKE_CASE				, _SCREAMING_SNAKE_CASE				):
														snake_case_           =		f"""Expected string as input, found {type(_SCREAMING_SNAKE_CASE				).__name__}"""
														raise TypeError(_SCREAMING_SNAKE_CASE				)

							snake_case_           =		spanish_id.replace("""-"""				, """"""				).upper()
							if len(_SCREAMING_SNAKE_CASE				) != 9:
														raise ValueError(_SCREAMING_SNAKE_CASE				)

							try:
														snake_case_           =		int(spanish_id_clean[0:8]				)
														snake_case_           =		spanish_id_clean[8]
							except ValueError as ex:
														raise ValueError(_SCREAMING_SNAKE_CASE				) from ex

							if letter.isdigit():
														raise ValueError(_SCREAMING_SNAKE_CASE				)

							return letter == LOOKUP_LETTERS[number % 23]


if __name__ == "__main__":
				import doctest

				doctest.testmod()



