


"""simple docstring"""






def        lowerCamelCase_(		_lowerCamelCase       )    ->     str:
   '''simple docstring'''





   if isinstance(_lowerCamelCase			,		_lowerCamelCase       ):
      raise TypeError("'float' object cannot be interpreted as an integer"       )
   if isinstance(_lowerCamelCase			,		_lowerCamelCase       ):
      raise TypeError("'str' object cannot be interpreted as an integer"       )

   if num == 0:
      return "0b0"

   _lowerCamelCase   :				Optional[Any]							=     False

   if num < 0:
      _lowerCamelCase   :				Tuple							=     True
      _lowerCamelCase   :				str							=     -num

   _lowerCamelCase   :				list[int]							=     []
   while num > 0:
      binary.insert(0			,		num % 2       )
      num >>= 1

   if negative:
      return "-0b" + "".join(str(_lowerCamelCase       ) for e in binary       )

   return "0b" + "".join(str(_lowerCamelCase       ) for e in binary       )


if __name__ == "__main__":
  import doctest

  doctest.testmod()





import argparse

import torch

from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel
from transformers.utils import logging


logging.set_verbosity_info()





def        __UpperCAmelCase						(							lowerCamelCase_ :     Dict  ,							lowerCamelCase_ :     Any  ,							lowerCamelCase_ :     int  ,							lowerCamelCase_ :     List[Any]  )       ->  int:







			"""simple docstring"""





			SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      FunnelConfig.from_json_file(lowerCamelCase_  )
			print(F'Building PyTorch model from configuration: {config}'  )
			SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      FunnelBaseModel(lowerCamelCase_  ) if base_model else FunnelModel(lowerCamelCase_  )

			# Load weights from tf checkpoint
			load_tf_weights_in_funnel(lowerCamelCase_  ,							lowerCamelCase_  ,							lowerCamelCase_  )

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


if __name__ == "__main__":
						UpperCamelCase__ :   Optional[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 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(
						    '''--base_model''', action='''store_true''', help='''Whether you want just the base model (no decoder) or not.'''
						)
						UpperCamelCase__ :   Tuple						=							parser.parse_args()
						convert_tf_checkpoint_to_pytorch(
						    args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path, args.base_model
						)



