


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


UpperCAmelCase       :	Any  		=						logging.get_logger(__name__)

UpperCAmelCase       :	str  		=						{
    "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__  (	__snake_case							):







					"""simple docstring"""


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






					def __init__(			self       :					Tuple					,			UpperCamelCase       :					Optional[int]=250_880					,			UpperCamelCase       :					str=64					,			UpperCamelCase       :					Union[str, Any]=2					,			UpperCamelCase       :					Union[str, Any]=8					,			UpperCamelCase       :					Dict=1e-5					,			UpperCamelCase       :					Optional[Any]=0.02					,			UpperCamelCase       :					Optional[Any]=True					,			UpperCamelCase       :					str=1					,			UpperCamelCase       :					int=2					,			UpperCamelCase       :					Any=False					,			UpperCamelCase       :					Dict=0.0					,			UpperCamelCase       :					str=0.0					,			UpperCamelCase       :					Any=1					,			UpperCamelCase       :					int=False					,			**UpperCamelCase       :					Tuple					,			):
												'''simple docstring'''






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

												__UpperCAmelCase  :		str 				=   bos_token_id
												__UpperCAmelCase  :		Union[str, Any] 				=   eos_token_id
												__UpperCAmelCase  :		Any 				=   slow_but_exact

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






class 	lowerCamelCase__  (	__snake_case							):







					"""simple docstring"""


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






					def __init__(			self       :					Tuple					,			UpperCamelCase       :					int					,			UpperCamelCase       :					Dict = "default"					,			UpperCamelCase       :					Optional[Any] = None					,			UpperCamelCase       :					Dict = False					,			):
												'''simple docstring'''






												super().__init__(a__					,			task=a__					,			patching_specs=a__					,			use_past=a__    )
												if not getattr(self._config					,			"""pad_token_id"""					,			a__    ):
																			# TODO: how to do that better?
																			__UpperCAmelCase  :		List[Any] 				=   0






					@property
					def lowerCamelCase__				(			self       :					Tuple    ):
												'''simple docstring'''






												__UpperCAmelCase  :		Optional[int] 				=   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_(a__					,			direction="""inputs"""					,			inverted_values_shape=a__    )
																			__UpperCAmelCase  :		int 				=   {0: """batch""", 1: """past_sequence + sequence"""}
												else:
																			__UpperCAmelCase  :		Dict 				=   {0: """batch""", 1: """sequence"""}

												return common_inputs






					@property
					def lowerCamelCase__				(			self       :					List[str]    ):
												'''simple docstring'''






												return self._config.n_layer






					@property
					def lowerCamelCase__				(			self       :					Tuple    ):
												'''simple docstring'''






												return self._config.n_head






					@property
					def lowerCamelCase__				(			self       :					List[Any]    ):
												'''simple docstring'''






												return 1e-3






					def lowerCamelCase__				(			self       :					List[str]					,			UpperCamelCase       :					Optional[int]					,			UpperCamelCase       :					Dict = -1					,			UpperCamelCase       :					int = -1					,			UpperCamelCase       :					Optional[int] = False					,			UpperCamelCase       :					Optional[Any] = None					,			):
												'''simple docstring'''






												__UpperCAmelCase  :		List[Any] 				=   super(a__					,			self    ).generate_dummy_inputs(
												    a__					,			batch_size=a__					,			seq_length=a__					,			is_pair=a__					,			framework=a__    )

												# We need to order the input in the way they appears in the forward()
												__UpperCAmelCase  :		Optional[Any] 				=   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  :		str 				=   common_inputs["""input_ids"""].shape
																										# Not using the same length for past_key_values
																										__UpperCAmelCase  :		int 				=   seqlen + 2
																										__UpperCAmelCase  :		str 				=   self._config.hidden_size // self.num_attention_heads
																										__UpperCAmelCase  :		Any 				=   (
																										    batch * self.num_attention_heads,
																										    head_dim,
																										    past_key_values_length,
																										)
																										__UpperCAmelCase  :		Optional[Any] 				=   (
																										    batch * self.num_attention_heads,
																										    past_key_values_length,
																										    head_dim,
																										)
																										__UpperCAmelCase  :		int 				=   [
																										    (torch.zeros(a__    ), torch.zeros(a__    )) for _ in range(self.num_layers    )
																										]

												__UpperCAmelCase  :		Dict 				=   common_inputs["""attention_mask"""]
												if self.use_past:
																			__UpperCAmelCase  :		List[str] 				=   ordered_inputs["""attention_mask"""].dtype
																			__UpperCAmelCase  :		Optional[Any] 				=   torch.cat(
																			    [ordered_inputs["""attention_mask"""], torch.ones(a__					,			a__					,			dtype=a__    )]					,			dim=1    )

												return ordered_inputs






					@property
					def lowerCamelCase__				(			self       :					Union[str, Any]    ):
												'''simple docstring'''






												return 13




from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments





def 	_lowerCAmelCase					( )			-> str:





	"""simple docstring"""







	A             =					HfArgumentParser(UpperCamelCase__    )
	A             =					parser.parse_args_into_dataclasses()[0]
	A             =					TensorFlowBenchmark(args=UpperCamelCase__    )
	try:
		A             =					parser.parse_args_into_dataclasses()[0]
	except ValueError as e:
		A             =					"""Arg --no_{0} is no longer used, please use --no-{0} instead."""
		A             =					""" """.join(str(UpperCamelCase__    ).split(""" """    )[:-1]    )
		A             =					""""""
		A             =					eval(str(UpperCamelCase__    ).split(""" """    )[-1]    )
		A             =					[]
		for arg in depreciated_args:
			# arg[2:] removes '--'
			if arg[2:] in TensorFlowBenchmark.deprecated_args:
				# arg[5:] removes '--no_'
				full_error_msg += arg_error_msg.format(arg[5:]    )
			else:
				wrong_args.append(UpperCamelCase__    )
		if len(UpperCamelCase__    ) > 0:
			A             =					full_error_msg + begin_error_msg + str(UpperCamelCase__    )
		raise ValueError(UpperCamelCase__    )
	benchmark.run()


if __name__ == "__main__":
				main()



