





'''simple docstring'''



import argparse

import torch

from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert
from transformers.utils import logging


logging.set_verbosity_info()




def 				_lowerCAmelCase  (			lowerCamelCase_     :					Union[str, Any]						,    lowerCamelCase_     :					Optional[int]						,    lowerCamelCase_     :					Union[str, Any]			):
			# Initialise PyTorch model
			__lowercase			  =							BertConfig.from_json_file(lowerCamelCase_			)
			print(f"Building PyTorch model from configuration: {config}"			)
			__lowercase			  =							BertForPreTraining(lowerCamelCase_			)

			# Load weights from tf checkpoint
			load_tf_weights_in_bert(lowerCamelCase_						,    lowerCamelCase_						,    lowerCamelCase_			)

			# Save pytorch-model
			print(f"Save PyTorch model to {pytorch_dump_path}"			)
			torch.save(model.state_dict()						,    lowerCamelCase_			)


if __name__ == "__main__":
	_SCREAMING_SNAKE_CASE   =      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(
	    '''--bert_config_file''',
	    default=None,
	    type=str,
	    required=True,
	    help=(
	        '''The config json file corresponding to the pre-trained BERT model. \n'''
	        '''This specifies the model architecture.'''
	    ),
	)
	parser.add_argument(
	    '''--pytorch_dump_path''', default=None, type=str, required=True, help='''Path to the output PyTorch model.'''
	)
	_SCREAMING_SNAKE_CASE   =      parser.parse_args()
	convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.bert_config_file, args.pytorch_dump_path)












'''simple docstring'''



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


_SCREAMING_SNAKE_CASE   =      logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE   =      {
    '''abeja/gpt-neox-japanese-2.7b''': '''https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config.json''',
}






class 							__lowercase    ( lowerCAmelCase__  ):







	'''simple docstring'''

	a      :			Union[str, Any]     =    "gpt_neox_japanese"


	def __init__(self       ,_lowerCamelCase=32000       ,_lowerCamelCase=2560       ,_lowerCamelCase=32       ,_lowerCamelCase=32       ,_lowerCamelCase=4       ,_lowerCamelCase="gelu"       ,_lowerCamelCase=1.0_0       ,_lowerCamelCase=10000       ,_lowerCamelCase=2048       ,_lowerCamelCase=0.0_2       ,_lowerCamelCase=1E-5       ,_lowerCamelCase=True       ,_lowerCamelCase=31996       ,_lowerCamelCase=31999       ,_lowerCamelCase=0.1       ,_lowerCamelCase=0.0       ,**_lowerCamelCase       ,)							->							Optional[int]:







				'''simple docstring'''





				super().__init__(bos_token_id=_lowerCamelCase       ,eos_token_id=_lowerCamelCase       ,**_lowerCamelCase	)
				__lowercase			  =							vocab_size
				__lowercase			  =							max_position_embeddings
				__lowercase			  =							hidden_size
				__lowercase			  =							num_hidden_layers
				__lowercase			  =							num_attention_heads
				__lowercase			  =							intermediate_multiple_size
				__lowercase			  =							hidden_act
				__lowercase			  =							rotary_pct
				__lowercase			  =							rotary_emb_base
				__lowercase			  =							initializer_range
				__lowercase			  =							layer_norm_eps
				__lowercase			  =							use_cache
				__lowercase			  =							attention_dropout
				__lowercase			  =							hidden_dropout





