



"""simple docstring"""






import doctest
import logging
import os
import unittest
from pathlib import Path
from typing import List, Union

import transformers
from transformers.testing_utils import require_tf, require_torch, slow


__snake_case							:     Any   =					logging.getLogger()



@unittest.skip('Temporarily disable the doc tests.'							)
@require_torch
@require_tf
@slow
class     A__     (						unittest.TestCase							):




	'''simple docstring'''





	def 							_SCREAMING_SNAKE_CASE     (  self:	Tuple ,    _SCREAMING_SNAKE_CASE:	Path ,    _SCREAMING_SNAKE_CASE:	Union[str, None] = None ,    _SCREAMING_SNAKE_CASE:	Union[List[str], None] = None ,    _SCREAMING_SNAKE_CASE:	Union[str, List[str], None] = None ,    _SCREAMING_SNAKE_CASE:	bool = True ,    )       -> Any:

				"""simple docstring"""

				__lowerCAmelCase   :						Union[str, Any]				= [file for file in os.listdir(_SCREAMING_SNAKE_CASE) if os.path.isfile(os.path.join(_SCREAMING_SNAKE_CASE ,    _SCREAMING_SNAKE_CASE))]

				if identifier is not None:
							__lowerCAmelCase   :						int				= [file for file in files if identifier in file]

				if n_identifier is not None:
							if isinstance(_SCREAMING_SNAKE_CASE ,    _SCREAMING_SNAKE_CASE):
										for n_ in n_identifier:
													__lowerCAmelCase   :						Dict				= [file for file in files if n_ not in file]
							else:
										__lowerCAmelCase   :						Union[str, Any]				= [file for file in files if n_identifier not in file]

				__lowerCAmelCase   :						List[str]				= ignore_files or []
				ignore_files.append("__init__.py")
				__lowerCAmelCase   :						Dict				= [file for file in files if file not in ignore_files]

				for file in files:
							# Open all files
							print("Testing" ,    _SCREAMING_SNAKE_CASE)

							if only_modules:
										__lowerCAmelCase   :						int				= file.split(".")[0]
										try:
													__lowerCAmelCase   :						List[Any]				= getattr(_SCREAMING_SNAKE_CASE ,    _SCREAMING_SNAKE_CASE)
													__lowerCAmelCase   :						Optional[Any]				= doctest.DocTestSuite(_SCREAMING_SNAKE_CASE)
													__lowerCAmelCase   :						List[str]				= unittest.TextTestRunner().run(_SCREAMING_SNAKE_CASE)
													self.assertIs(len(result.failures) ,    0)
										except AttributeError:
													logger.info(F"""{module_identifier} is not a module.""")
							else:
										__lowerCAmelCase   :						Tuple				= doctest.testfile(str(".." / directory / file) ,    optionflags=doctest.ELLIPSIS)
										self.assertIs(result.failed ,    0)

	def 							_SCREAMING_SNAKE_CASE     (  self:	Any)       -> Dict:

				"""simple docstring"""

				__lowerCAmelCase   :						Dict				= Path("src/transformers")
				__lowerCAmelCase   :						Tuple				= "modeling"
				__lowerCAmelCase   :						Optional[int]				= [
				    "modeling_ctrl.py",
				    "modeling_tf_ctrl.py",
				]
				self.analyze_directory(_SCREAMING_SNAKE_CASE ,    identifier=_SCREAMING_SNAKE_CASE ,    ignore_files=_SCREAMING_SNAKE_CASE)

	def 							_SCREAMING_SNAKE_CASE     (  self:	List[Any])       -> Optional[Any]:

				"""simple docstring"""

				__lowerCAmelCase   :						int				= Path("src/transformers")
				__lowerCAmelCase   :						Optional[Any]				= "tokenization"
				self.analyze_directory(_SCREAMING_SNAKE_CASE ,    identifier=_SCREAMING_SNAKE_CASE)

	def 							_SCREAMING_SNAKE_CASE     (  self:	List[str])       -> int:

				"""simple docstring"""

				__lowerCAmelCase   :						Optional[int]				= Path("src/transformers")
				__lowerCAmelCase   :						int				= "configuration"
				self.analyze_directory(_SCREAMING_SNAKE_CASE ,    identifier=_SCREAMING_SNAKE_CASE)

	def 							_SCREAMING_SNAKE_CASE     (  self:	Dict)       -> int:

				"""simple docstring"""

				__lowerCAmelCase   :						Optional[int]				= Path("src/transformers")
				__lowerCAmelCase   :						Union[str, Any]				= ["configuration", "modeling", "tokenization"]
				self.analyze_directory(_SCREAMING_SNAKE_CASE ,    n_identifier=_SCREAMING_SNAKE_CASE)







	def 							_SCREAMING_SNAKE_CASE     (  self:	Any)       -> List[Any]:

				"""simple docstring"""

				__lowerCAmelCase   :						Dict				= Path("docs/source")
				__lowerCAmelCase   :						Optional[int]				= ["favicon.ico"]
				self.analyze_directory(_SCREAMING_SNAKE_CASE ,    ignore_files=_SCREAMING_SNAKE_CASE ,    only_modules=_SCREAMING_SNAKE_CASE)




"""simple docstring"""






import argparse

import torch

from ...utils import logging
from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert


logging.set_verbosity_info()


def     _lowercase       (						__snake_case      ,__snake_case      ,__snake_case			)		->     Tuple:
			# Initialise PyTorch model
			__lowerCAmelCase   :						Any				= AlbertConfig.from_json_file(__snake_case			)
			print(F"""Building PyTorch model from configuration: {config}"""			)
			__lowerCAmelCase   :						str				= AlbertForPreTraining(__snake_case			)

			# Load weights from tf checkpoint
			load_tf_weights_in_albert(__snake_case      ,__snake_case      ,__snake_case			)

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


if __name__ == "__main__":
	__snake_case							:     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(
	    '--albert_config_file',
	    default=None,
	    type=str,
	    required=True,
	    help=(
	        'The config json file corresponding to the pre-trained ALBERT 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.'
	)
	__snake_case							:     str   =					parser.parse_args()
	convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.albert_config_file, args.pytorch_dump_path)