



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


__snake_case				:		Optional[int]										=logging.get_logger(__name__)

__snake_case				:		int										={
    '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        lowerCamelCase__			(							lowercase_):




		'''simple docstring'''



		snake_case_	="""bloom"""
		snake_case_	=["""past_key_values"""]
		snake_case_	={
		    """num_hidden_layers""": """n_layer""",
		    """num_attention_heads""": """n_head""",
		}



		def __init__(self		,__lowerCamelCase=25_08_80		,__lowerCamelCase=64		,__lowerCamelCase=2		,__lowerCamelCase=8		,__lowerCamelCase=1e-5		,__lowerCamelCase=0.02		,__lowerCamelCase=True		,__lowerCamelCase=1		,__lowerCamelCase=2		,__lowerCamelCase=False		,__lowerCamelCase=0.0		,__lowerCamelCase=0.0		,__lowerCamelCase=1		,__lowerCamelCase=False		,**__lowerCamelCase		,)     ->			str:

						"""simple docstring"""






						lowerCAmelCase__     :				Union[str, Any]												=     vocab_size
						# Backward compatibility with n_embed kwarg
						lowerCAmelCase__     :				str												=     kwargs.pop('''n_embed'''		,__lowerCamelCase )
						lowerCAmelCase__     :				Any												=     hidden_size if n_embed is None else n_embed
						lowerCAmelCase__     :				Optional[Any]												=     n_layer
						lowerCAmelCase__     :				int												=     n_head
						lowerCAmelCase__     :				Dict												=     layer_norm_epsilon
						lowerCAmelCase__     :				str												=     initializer_range
						lowerCAmelCase__     :				Union[str, Any]												=     use_cache
						lowerCAmelCase__     :				int												=     pretraining_tp
						lowerCAmelCase__     :				str												=     apply_residual_connection_post_layernorm
						lowerCAmelCase__     :				List[str]												=     hidden_dropout
						lowerCAmelCase__     :				int												=     attention_dropout

						lowerCAmelCase__     :				Dict												=     bos_token_id
						lowerCAmelCase__     :				Union[str, Any]												=     eos_token_id
						lowerCAmelCase__     :				Dict												=     slow_but_exact

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



class        lowerCamelCase__			(							lowercase_):




		'''simple docstring'''



		snake_case_	=version.parse("""1.12""")



		def __init__(self		,__lowerCamelCase		,__lowerCamelCase = "default"		,__lowerCamelCase = None		,__lowerCamelCase = False		,)     ->			Any:

						"""simple docstring"""






						super().__init__(__lowerCamelCase		,task=__lowerCamelCase		,patching_specs=__lowerCamelCase		,use_past=__lowerCamelCase )
						if not getattr(self._config		,'''pad_token_id'''		,__lowerCamelCase ):
										# TODO: how to do that better?
										lowerCAmelCase__     :				Tuple												=     0



		@property
		def 		lowerCAmelCase__      (self )     ->			Tuple:

						"""simple docstring"""






						lowerCAmelCase__     :				str												=     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_(__lowerCamelCase		,direction='''inputs'''		,inverted_values_shape=__lowerCamelCase )
										lowerCAmelCase__     :				Any												=     {0: '''batch''', 1: '''past_sequence + sequence'''}
						else:
										lowerCAmelCase__     :				Union[str, Any]												=     {0: '''batch''', 1: '''sequence'''}

						return common_inputs



		@property
		def 		lowerCAmelCase__      (self )     ->			Tuple:

						"""simple docstring"""






						return self._config.n_layer



		@property
		def 		lowerCAmelCase__      (self )     ->			List[str]:

						"""simple docstring"""






						return self._config.n_head



		@property
		def 		lowerCAmelCase__      (self )     ->			Any:

						"""simple docstring"""






						return 1e-3



		def 		lowerCAmelCase__      (self		,__lowerCamelCase		,__lowerCamelCase = -1		,__lowerCamelCase = -1		,__lowerCamelCase = False		,__lowerCamelCase = None		,)     ->			List[str]:

						"""simple docstring"""






						lowerCAmelCase__     :				int												=     super(__lowerCamelCase		,self ).generate_dummy_inputs(
						    __lowerCamelCase		,batch_size=__lowerCamelCase		,seq_length=__lowerCamelCase		,is_pair=__lowerCamelCase		,framework=__lowerCamelCase )

						# We need to order the input in the way they appears in the forward()
						lowerCAmelCase__     :				List[str]												=     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

														lowerCAmelCase__						,		lowerCAmelCase__     :				Tuple												=     common_inputs['''input_ids'''].shape
														# Not using the same length for past_key_values
														lowerCAmelCase__     :				List[Any]												=     seqlen + 2
														lowerCAmelCase__     :				List[Any]												=     self._config.hidden_size // self.num_attention_heads
														lowerCAmelCase__     :				List[Any]												=     (
														    batch * self.num_attention_heads,
														    head_dim,
														    past_key_values_length,
														)
														lowerCAmelCase__     :				List[Any]												=     (
														    batch * self.num_attention_heads,
														    past_key_values_length,
														    head_dim,
														)
														lowerCAmelCase__     :				Optional[Any]												=     [
														    (torch.zeros(__lowerCamelCase ), torch.zeros(__lowerCamelCase )) for _ in range(self.num_layers )
														]

						lowerCAmelCase__     :				Any												=     common_inputs['''attention_mask''']
						if self.use_past:
										lowerCAmelCase__     :				Optional[Any]												=     ordered_inputs['''attention_mask'''].dtype
										lowerCAmelCase__     :				Optional[int]												=     torch.cat(
										    [ordered_inputs['''attention_mask'''], torch.ones(__lowerCamelCase		,__lowerCamelCase		,dtype=__lowerCamelCase )]		,dim=1 )

						return ordered_inputs



		@property
		def 		lowerCAmelCase__      (self )     ->			int:

						"""simple docstring"""






						return 13





'''simple docstring'''

from __future__ import annotations

def _SCREAMING_SNAKE_CASE      (A       )       ->       bool:






       """simple docstring"""







       return len(set(A       )       ) == len(A       )


if __name__ == "__main__":
 import doctest

 doctest.testmod()




