




import argparse

import torch

from transformers import ElectraConfig, ElectraForMaskedLM, ElectraForPreTraining, load_tf_weights_in_electra
from transformers.utils import logging


logging.set_verbosity_info()







def  lowerCAmelCase  (	UpperCAmelCase,	UpperCAmelCase,	UpperCAmelCase,	UpperCAmelCase       )  ->Tuple:






					"""simple docstring"""






					__magic_name__					:							List[Any]		   =							ElectraConfig.from_json_file(UpperCAmelCase       )
					print(F'''Building PyTorch model from configuration: {config}'''       )

					if discriminator_or_generator == "discriminator":
										__magic_name__					:							Union[str, Any]		   =							ElectraForPreTraining(UpperCAmelCase       )
					elif discriminator_or_generator == "generator":
										__magic_name__					:							str		   =							ElectraForMaskedLM(UpperCAmelCase       )
					else:
										raise ValueError('''The discriminator_or_generator argument should be either \'discriminator\' or \'generator\''''       )

					# Load weights from tf checkpoint
					load_tf_weights_in_electra(
					    UpperCAmelCase,	UpperCAmelCase,	UpperCAmelCase,	discriminator_or_generator=UpperCAmelCase       )

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


if __name__ == "__main__":
				lowercase_		=							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 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.'''
				)
				parser.add_argument(
				    '''--discriminator_or_generator''',
				    default=None,
				    type=str,
				    required=True,
				    help=(
				        '''Whether to export the generator or the discriminator. Should be a string, either \'discriminator\' or '''
				        '''\'generator\'.'''
				    ),
				)
				lowercase_		=							parser.parse_args()
				convert_tf_checkpoint_to_pytorch(
				    args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path, args.discriminator_or_generator
				)





"""simple docstring"""




from functools import lru_cache

@lru_cache
def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_			):
					if not isinstance(SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			):
										raise TypeError('k must be an integer.'			)
					if k < 0:
										raise ValueError('k integer must be greater or equal to zero.'			)
					if k == 0:
										return 0
					elif k == 1:
										return 1
					else:
										return fibonacci(k - 1			) + fibonacci(k - 2			)

def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			):
					SCREAMING_SNAKE_CASE				=	len(SCREAMING_SNAKE_CASE_			)
					# Find m such that F_m >= n where F_i is the i_th fibonacci number.
					SCREAMING_SNAKE_CASE				=	0
					while True:
										if fibonacci(SCREAMING_SNAKE_CASE_			) >= len_list:
															SCREAMING_SNAKE_CASE				=	i
															break
										i += 1
					SCREAMING_SNAKE_CASE				=	0
					while fibb_k > 0:
										SCREAMING_SNAKE_CASE				=	min(
										    offset + fibonacci(fibb_k - 1			),     len_list - 1			)  # Prevent out of range
										SCREAMING_SNAKE_CASE				=	arr[index_k]
										if item_k_1 == val:
															return index_k
										elif val < item_k_1:
															fibb_k -= 1
										elif val > item_k_1:
															offset += fibonacci(fibb_k - 1			)
															fibb_k -= 2
					else:
										return -1


if __name__ == "__main__":
	import doctest

	doctest.testmod()
