


'''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


__snake_case											=					logging.get_logger(__name__)

__snake_case											=					{
    '''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        lowercase     (							A__ ):

		"""simple docstring"""

		_a   			=    'bloom'
		_a   			=    ['past_key_values']
		_a   			=    {
		    'num_hidden_layers': 'n_layer',
		    'num_attention_heads': 'n_head',
		}




		def __init__(		self   ,       UpperCamelCase_=250880   ,       UpperCamelCase_=64   ,       UpperCamelCase_=2   ,       UpperCamelCase_=8   ,       UpperCamelCase_=1e-5   ,       UpperCamelCase_=0.02   ,       UpperCamelCase_=True   ,       UpperCamelCase_=1   ,       UpperCamelCase_=2   ,       UpperCamelCase_=False   ,       UpperCamelCase_=0.0   ,       UpperCamelCase_=0.0   ,       UpperCamelCase_=1   ,       UpperCamelCase_=False   ,       **UpperCamelCase_   ,       ):

							'''simple docstring'''


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

							UpperCamelCase__       :List[Any]							 =			bos_token_id
							UpperCamelCase__       :Optional[int]							 =			eos_token_id
							UpperCamelCase__       :List[Any]							 =			slow_but_exact

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



class        lowercase     (							A__ ):

		"""simple docstring"""

		_a   			=    version.parse('1.12' )




		def __init__(		self   ,       UpperCamelCase_   ,       UpperCamelCase_ = "default"   ,       UpperCamelCase_ = None   ,       UpperCamelCase_ = False   ,       ):

							'''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?
												UpperCamelCase__       :List[str]							 =			0




		@property
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Union[str, Any]							 =			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_							)
												UpperCamelCase__       :Dict							 =			{0: '''batch''', 1: '''past_sequence + sequence'''}
							else:
												UpperCamelCase__       :str							 =			{0: '''batch''', 1: '''sequence'''}

							return common_inputs




		@property
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							return self._config.n_layer




		@property
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							return self._config.n_head




		@property
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							return 1e-3




		def    lowerCAmelCase__    (		self   ,       UpperCamelCase_   ,       UpperCamelCase_ = -1   ,       UpperCamelCase_ = -1   ,       UpperCamelCase_ = False   ,       UpperCamelCase_ = None   ,       ):

							'''simple docstring'''


							UpperCamelCase__       :List[Any]							 =			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()
							UpperCamelCase__       :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

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

							UpperCamelCase__       :Optional[int]							 =			common_inputs['''attention_mask''']
							if self.use_past:
												UpperCamelCase__       :List[str]							 =			ordered_inputs['''attention_mask'''].dtype
												UpperCamelCase__       :Tuple							 =			torch.cat(
												    [ordered_inputs['''attention_mask'''], torch.ones(UpperCamelCase_   ,       UpperCamelCase_   ,       dtype=UpperCamelCase_							)]   ,       dim=1							)

							return ordered_inputs




		@property
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							return 13



'''simple docstring'''
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__snake_case											=					{'''configuration_vit_msn''': ['''VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMSNConfig''']}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__snake_case											=					[
		    '''VIT_MSN_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''ViTMSNModel''',
		    '''ViTMSNForImageClassification''',
		    '''ViTMSNPreTrainedModel''',
		]

if TYPE_CHECKING:
		from .configuration_vit_msn import VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTMSNConfig

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_vit_msn import (
				    VIT_MSN_PRETRAINED_MODEL_ARCHIVE_LIST,
				    ViTMSNForImageClassification,
				    ViTMSNModel,
				    ViTMSNPreTrainedModel,
				)

else:
		import sys

		__snake_case											=					_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)