

# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import re

from ..utils import cached_file


# docstyle-ignore
_UpperCAmelCase						:  Tuple									=			"""
Human: <<task>>

Assistant: """


_UpperCAmelCase						:  List[str]									=			"""huggingface-tools/default-prompts"""
_UpperCAmelCase						:  Any									=			{"""chat""": """chat_prompt_template.txt""", """run""": """run_prompt_template.txt"""}





def    __lowerCamelCase      (					UpperCamelCase__  ,				UpperCamelCase__  ,				UpperCamelCase__="run" ):







							'''simple docstring'''






							if prompt_or_repo_id is None:
														snake_case_     							=       DEFAULT_PROMPTS_REPO

							# prompt is considered a repo ID when it does not contain any kind of space
							if re.search('\\s'  ,				UpperCamelCase__ ) is not None:
														return prompt_or_repo_id

							snake_case_     							=       cached_file(
							    UpperCamelCase__  ,				PROMPT_FILES[mode]  ,				repo_type='dataset'  ,				user_agent={'agent': agent_name} )
							with open(UpperCamelCase__  ,				'r'  ,				encoding='utf-8' ) as f:
														return f.read()







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      (					UpperCamelCase__  ,				UpperCamelCase__  ,				UpperCamelCase__ ):







							'''simple docstring'''






							snake_case_     							=       BertConfig.from_json_file(UpperCamelCase__ )
							print(F'''Building PyTorch model from configuration: {config}''' )
							snake_case_     							=       BertForPreTraining(UpperCamelCase__ )

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

							# Save pytorch-model
							print(F'''Save PyTorch model to {pytorch_dump_path}''' )
							torch.save(model.state_dict()  ,				UpperCamelCase__ )


if __name__ == "__main__":
					_UpperCAmelCase						:  Union[str, Any]									=			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."""
					)
					_UpperCAmelCase						:  Any									=			parser.parse_args()
					convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.bert_config_file, args.pytorch_dump_path)




