



'''simple docstring'''



import os
import sys

lowerCAmelCase_  :							Optional[Any]             =    os.path.join(os.path.dirname(__file__), 'src')
sys.path.append(SRC_DIR)


from transformers import (
    AutoConfig,
    AutoModel,
    AutoModelForCausalLM,
    AutoModelForMaskedLM,
    AutoModelForQuestionAnswering,
    AutoModelForSequenceClassification,
    AutoTokenizer,
    add_start_docstrings,
)


lowerCAmelCase_  :							Any             =    [
    'torch',
    'numpy',
    'tokenizers',
    'filelock',
    'requests',
    'tqdm',
    'regex',
    'sentencepiece',
    'sacremoses',
    'importlib_metadata',
    'huggingface_hub',
]
@add_start_docstrings(AutoConfig.__doc__					)
def        UpperCAmelCase (    *A	:					Dict       ,		**A	:					Optional[Any]					):
							return AutoConfig.from_pretrained(*A       ,		**A					)
@add_start_docstrings(AutoTokenizer.__doc__					)
def        UpperCAmelCase (    *A	:					List[str]       ,		**A	:					Optional[Any]					):
							return AutoTokenizer.from_pretrained(*A       ,		**A					)
@add_start_docstrings(AutoModel.__doc__					)
def        UpperCAmelCase (    *A	:					Tuple       ,		**A	:					Union[str, Any]					):
							return AutoModel.from_pretrained(*A       ,		**A					)
@add_start_docstrings(AutoModelForCausalLM.__doc__					)
def        UpperCAmelCase (    *A	:					List[str]       ,		**A	:					str					):
							return AutoModelForCausalLM.from_pretrained(*A       ,		**A					)
@add_start_docstrings(AutoModelForMaskedLM.__doc__					)
def        UpperCAmelCase (    *A	:					Optional[int]       ,		**A	:					int					):
							return AutoModelForMaskedLM.from_pretrained(*A       ,		**A					)
@add_start_docstrings(AutoModelForSequenceClassification.__doc__					)
def        UpperCAmelCase (    *A	:					List[str]       ,		**A	:					Tuple					):
							return AutoModelForSequenceClassification.from_pretrained(*A       ,		**A					)






@add_start_docstrings(AutoModelForQuestionAnswering.__doc__					)
def        UpperCAmelCase (    *A	:					Optional[Any]       ,		**A	:					Any					):
							return AutoModelForQuestionAnswering.from_pretrained(*A       ,		**A					)









'''simple docstring'''



import argparse

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


logging.set_verbosity_info()
def        UpperCAmelCase (    A	:					Optional[Any]       ,		A	:					Optional[int]       ,		A	:					int					):
							# Initialise PyTorch model
							SCREAMING_SNAKE_CASE       :   str         =      TaConfig.from_json_file(A					)
							print(F"""Building PyTorch model from configuration: {config}"""					)
							SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      TaForConditionalGeneration(A					)

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

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


if __name__ == "__main__":
							lowerCAmelCase_  :							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(
							    '--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.'
							)
							lowerCAmelCase_  :							Tuple             =    parser.parse_args()
							convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path)




