



from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCAmelCase__     = logging.get_logger(__name__)

UpperCAmelCase__     = {
    "s-JoL/Open-Llama-V1": "https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json",
}







class     __lowerCAmelCase					(    A		):
			UpperCamelCase           =  '''open-llama'''



			def __init__(		self     :						Dict				,	A     :						Optional[Any]=10_00_00				,	A     :						Any=40_96				,	A     :						Dict=1_10_08				,	A     :						Optional[Any]=32				,	A     :						List[Any]=32				,	A     :						List[Any]="silu"				,	A     :						Optional[Any]=20_48				,	A     :						Dict=0.0_2				,	A     :						Union[str, Any]=1E-6				,	A     :						str=True				,	A     :						List[str]=0				,	A     :						Tuple=1				,	A     :						str=2				,	A     :						Dict=False				,	A     :						Any=True				,	A     :						Any=0.1				,	A     :						Optional[Any]=0.1				,	A     :						int=True				,	A     :						Optional[int]=True				,	A     :						Optional[int]=None				,	**A     :						Optional[Any]				,	)     ->					List[Any]:



						"""simple docstring"""






						_UpperCAmelCase	 =     vocab_size
						_UpperCAmelCase	 =     max_position_embeddings
						_UpperCAmelCase	 =     hidden_size
						_UpperCAmelCase	 =     intermediate_size
						_UpperCAmelCase	 =     num_hidden_layers
						_UpperCAmelCase	 =     num_attention_heads
						_UpperCAmelCase	 =     hidden_act
						_UpperCAmelCase	 =     initializer_range
						_UpperCAmelCase	 =     rms_norm_eps
						_UpperCAmelCase	 =     use_cache
						_UpperCAmelCase	 =     kwargs.pop(
						    'use_memorry_efficient_attention'				,	A)
						_UpperCAmelCase	 =     hidden_dropout_prob
						_UpperCAmelCase	 =     attention_dropout_prob
						_UpperCAmelCase	 =     use_stable_embedding
						_UpperCAmelCase	 =     shared_input_output_embedding
						_UpperCAmelCase	 =     rope_scaling
						self._rope_scaling_validation()

						super().__init__(
						    pad_token_id=A				,	bos_token_id=A				,	eos_token_id=A				,	tie_word_embeddings=A				,	**A				,	)



			def 					_lowerCamelCase (		self     :						Tuple)     ->					Any:



						"""simple docstring"""






						if self.rope_scaling is None:
									return

						if not isinstance(self.rope_scaling				,	A) or len(self.rope_scaling) != 2:
									raise ValueError(
									    '`rope_scaling` must be a dictionary with with two fields, `name` and `factor`, '
									    F"got {self.rope_scaling}")
						_UpperCAmelCase	 =     self.rope_scaling.get('type'				,	A)
						_UpperCAmelCase	 =     self.rope_scaling.get('factor'				,	A)
						if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
									raise ValueError(
									    F"`rope_scaling`'s name field must be one of ['linear', 'dynamic'], got {rope_scaling_type}")
						if rope_scaling_factor is None or not isinstance(A				,	A) or rope_scaling_factor <= 1.0:
									raise ValueError(F"`rope_scaling`'s factor field must be an float > 1, got {rope_scaling_factor}")





import argparse

from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta
from transformers.utils import logging


logging.set_verbosity_info()





def 							A			(  _UpperCAmelCase       :     Optional[Any]							,     _UpperCAmelCase       :     Union[str, Any]							,     _UpperCAmelCase       :     Optional[int]					)       ->				int:







			'''simple docstring'''
			# Initialise PyTorch model
			_UpperCAmelCase	 =     TaConfig.from_json_file(_UpperCAmelCase					)
			print(F"Building PyTorch model from configuration: {config}"					)
			_UpperCAmelCase	 =     TaForConditionalGeneration(_UpperCAmelCase					)

			# Load weights from tf checkpoint
			load_tf_weights_in_ta(_UpperCAmelCase							,     _UpperCAmelCase							,     _UpperCAmelCase					)

			# Save pytorch-model
			print(F"Save PyTorch model to {pytorch_dump_path}"					)
			model.save_pretrained(_UpperCAmelCase					)


if __name__ == "__main__":
							UpperCAmelCase__     = argparse.ArgumentParser()
							# Required parameters
							parser.add_argument(
							    "--tf_checkpoint_path", default=None, type=str, required=True, help="Path to the TensorFlow checkpoint path."
							)
							parser.add_argument(
							    "--config_file",
							    default=None,
							    type=str,
							    required=True,
							    help=(
							        "The config json file corresponding to the pre-trained T5 model. \nThis specifies the model architecture."
							    ),
							)
							parser.add_argument(
							    "--pytorch_dump_path", default=None, type=str, required=True, help="Path to the output PyTorch model."
							)
							UpperCAmelCase__     = parser.parse_args()
							convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path)
