


'''simple docstring'''



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


_lowercase    :    Tuple			     =  logging.get_logger(__name__)

_lowercase    :    int			     =  {
    """bigcode/gpt_bigcode-santacoder""": """https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json""",
}






class  UpperCamelCase__(     lowerCAmelCase ):
				__magic_name__       :   Union[str, Any]							= "gpt_bigcode"
				__magic_name__       :   List[Any]							= ["past_key_values"]
				__magic_name__       :   Optional[Any]							= {
				    "hidden_size": "n_embd",
				    "max_position_embeddings": "n_positions",
				    "num_attention_heads": "n_head",
				    "num_hidden_layers": "n_layer",
				}




				def __init__(	self    :				Any   ,					lowerCAmelCase    :				Any=50257   ,					lowerCAmelCase    :				Dict=1024   ,					lowerCAmelCase    :				str=768   ,					lowerCAmelCase    :				Any=12   ,					lowerCAmelCase    :				str=12   ,					lowerCAmelCase    :				str=None   ,					lowerCAmelCase    :				Optional[int]="gelu_pytorch_tanh"   ,					lowerCAmelCase    :				Tuple=0.1   ,					lowerCAmelCase    :				Tuple=0.1   ,					lowerCAmelCase    :				Any=0.1   ,					lowerCAmelCase    :				List[str]=1E-5   ,					lowerCAmelCase    :				Tuple=0.02   ,					lowerCAmelCase    :				Dict=True   ,					lowerCAmelCase    :				Optional[int]=True   ,					lowerCAmelCase    :				List[Any]=50256   ,					lowerCAmelCase    :				List[Any]=50256   ,					lowerCAmelCase    :				List[Any]=True   ,					lowerCAmelCase    :				Optional[Any]=True   ,					lowerCAmelCase    :				str=True   ,					**lowerCAmelCase    :				Tuple   ,					)->  int:

										"""simple docstring"""




										UpperCAmelCase         =			vocab_size
										UpperCAmelCase         =			n_positions
										UpperCAmelCase         =			n_embd
										UpperCAmelCase         =			n_layer
										UpperCAmelCase         =			n_head
										UpperCAmelCase         =			n_inner
										UpperCAmelCase         =			activation_function
										UpperCAmelCase         =			resid_pdrop
										UpperCAmelCase         =			embd_pdrop
										UpperCAmelCase         =			attn_pdrop
										UpperCAmelCase         =			layer_norm_epsilon
										UpperCAmelCase         =			initializer_range
										UpperCAmelCase         =			scale_attn_weights
										UpperCAmelCase         =			use_cache
										UpperCAmelCase         =			attention_softmax_in_fpaa
										UpperCAmelCase         =			scale_attention_softmax_in_fpaa
										UpperCAmelCase         =			multi_query

										UpperCAmelCase         =			bos_token_id
										UpperCAmelCase         =			eos_token_id

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









'''simple docstring'''



import argparse

from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird
from transformers.utils import logging


logging.set_verbosity_info()


def    lowerCamelCase__   ( A     :    List[Any]   ,     A     :    int   ,     A     :    List[str]   ,     A     :    Optional[int]  ):




						'''simple docstring'''






						UpperCAmelCase         =			BigBirdConfig.from_json_file(A  )
						print(f"""Building PyTorch model from configuration: {config}"""  )

						if is_trivia_qa:
												UpperCAmelCase         =			BigBirdForQuestionAnswering(A  )
						else:
												UpperCAmelCase         =			BigBirdForPreTraining(A  )

						# Load weights from tf checkpoint
						load_tf_weights_in_big_bird(A   ,     A   ,     is_trivia_qa=A  )

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


if __name__ == "__main__":
	_lowercase    :    List[str]			     =  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(
	    """--big_bird_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."""
	)
	parser.add_argument(
	    """--is_trivia_qa""", action="""store_true""", help="""Whether to convert a model with a trivia_qa head."""
	)
	_lowercase    :    Any			     =  parser.parse_args()
	convert_tf_checkpoint_to_pytorch(
	    args.tf_checkpoint_path, args.big_bird_config_file, args.pytorch_dump_path, args.is_trivia_qa
	)





