





import argparse

from transformers import ConvBertConfig, ConvBertModel, TFConvBertModel, load_tf_weights_in_convbert
from transformers.utils import logging


logging.set_verbosity_info()

def      __snake_case						(					_lowerCAmelCase : int				,				_lowerCAmelCase : Union[str, Any]				,				_lowerCAmelCase : Union[str, Any]	) ->						Union[str, Any]:
   A_					:				List[Any]          =			ConvBertConfig.from_json_file(_lowerCAmelCase	)
   A_					:				List[str]          =			ConvBertModel(_lowerCAmelCase	)

   A_					:				List[Any]          =			load_tf_weights_in_convbert(_lowerCAmelCase				,				_lowerCAmelCase				,				_lowerCAmelCase	)
   model.save_pretrained(_lowerCAmelCase	)

   A_					:				Optional[int]          =			TFConvBertModel.from_pretrained(_lowerCAmelCase				,				from_pt=_lowerCAmelCase	)
   tf_model.save_pretrained(_lowerCAmelCase	)


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






def      __snake_case						(					_lowerCAmelCase : int				,				_lowerCAmelCase : int = 1000	) ->						str:
   if (not isinstance(_lowerCAmelCase				,				_lowerCAmelCase	)) or (digit_position <= 0):
      raise ValueError("Digit position must be a positive integer"	)
   elif (not isinstance(_lowerCAmelCase				,				_lowerCAmelCase	)) or (precision < 0):
      raise ValueError("Precision must be a nonnegative integer"	)

   # compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
   # accurate
   A_					:				List[str]          =			(
       4 * _subsum(_lowerCAmelCase				,				1				,				_lowerCAmelCase	)
       - 2 * _subsum(_lowerCAmelCase				,				4				,				_lowerCAmelCase	)
       - _subsum(_lowerCAmelCase				,				5				,				_lowerCAmelCase	)
       - _subsum(_lowerCAmelCase				,				6				,				_lowerCAmelCase	)
   )

   # return the first hex digit of the fractional part of the result
   return hex(int((sum_result % 1) * 16	)	)[2:]

def      __snake_case						(					_lowerCAmelCase : int				,				_lowerCAmelCase : int				,				_lowerCAmelCase : int	) ->						float:
   A_					:				int          =			0.0
   for sum_index in range(digit_pos_to_extract + precision	):
      A_					:				Optional[int]          =			8 * sum_index + denominator_addend
      if sum_index < digit_pos_to_extract:
         # if the exponential term is an integer and we mod it by the denominator
         # before dividing, only the integer part of the sum will change;
         # the fractional part will not
         A_					:				Optional[Any]          =			pow(
             16				,				digit_pos_to_extract - 1 - sum_index				,				_lowerCAmelCase	)
      else:
         A_					:				Tuple          =			pow(16				,				digit_pos_to_extract - 1 - sum_index	)
      total += exponential_term / denominator
   return total


if __name__ == "__main__":
 import doctest

 doctest.testmod()
