

'''simple docstring'''






import logging
import os
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

from tqdm import auto as tqdm_lib


lowerCAmelCase__      		=			{
    '''debug''': logging.DEBUG,
    '''info''': logging.INFO,
    '''warning''': logging.WARNING,
    '''error''': logging.ERROR,
    '''critical''': logging.CRITICAL,
}

lowerCAmelCase__      		=			logging.WARNING


def 	_A  (					):






 """simple docstring"""



 __lowercase													=				os.getenv('''DATASETS_VERBOSITY'''  ,       A__   )
 if env_level_str:
  if env_level_str in log_levels:
   return log_levels[env_level_str]
  else:
   logging.getLogger().warning(
       F"Unknown option DATASETS_VERBOSITY={env_level_str}, "
       F"has to be one of: { ', '.join(log_levels.keys()   ) }"   )
 return _default_log_level


def 	_A  (					):






 """simple docstring"""



 return __name__.split('''.'''   )[0]


def 	_A  (					):






 """simple docstring"""



 return logging.getLogger(_get_library_name()   )


def 	_A  (					):






 """simple docstring"""



 __lowercase													=				_get_library_root_logger()
 library_root_logger.setLevel(_get_default_logging_level()   )


def 	_A  (					):






 """simple docstring"""



 __lowercase													=				_get_library_root_logger()
 library_root_logger.setLevel(logging.NOTSET   )


def 	_A  (					A__ = None   ):






 """simple docstring"""



 if name is None:
  __lowercase													=				_get_library_name()
 return logging.getLogger(A__   )


def 	_A  (					):






 """simple docstring"""



 return _get_library_root_logger().getEffectiveLevel()


def 	_A  (					A__   ):






 """simple docstring"""



 _get_library_root_logger().setLevel(A__   )


def 	_A  (					):






 """simple docstring"""



 return set_verbosity(A__   )


def 	_A  (					):






 """simple docstring"""



 return set_verbosity(A__   )


def 	_A  (					):






 """simple docstring"""



 return set_verbosity(A__   )


def 	_A  (					):






 """simple docstring"""



 return set_verbosity(A__   )


def 	_A  (					):






 """simple docstring"""



 __lowercase													=				False


def 	_A  (					):






 """simple docstring"""



 __lowercase													=				True


# Configure the library root logger at the module level (singleton-like)
_configure_library_root_logger()






class     lowercase_			:




  """simple docstring"""




  def __init__(   self     :  Optional[int]      ,*lowercase__     :  Any      ,**lowercase__     :  int    ):  # pylint: disable=unused-argument
   __lowercase													=				args[0] if args else None






  def __iter__(   self     :  Any    ):
   return iter(self._iterator    )






  def __getattr__(   self     :  Union[str, Any]      ,lowercase__     :  List[str]    ):

   def empty_fn(*lowercase__     :  Dict      ,**lowercase__     :  int    ):  # pylint: disable=unused-argument
    return

   return empty_fn






  def __enter__(   self     :  Union[str, Any]    ):
   return self






  def __exit__(   self     :  str      ,lowercase__     :  str      ,lowercase__     :  Tuple      ,lowercase__     :  List[str]    ):
   return
lowerCAmelCase__      		=			True






class     lowercase_			:




  """simple docstring"""




  def __call__(   self     :  Optional[int]      ,*lowercase__     :  Union[str, Any]      ,lowercase__     :  List[Any]=False      ,**lowercase__     :  Optional[Any]    ):
   if _tqdm_active and not disable:
    return tqdm_lib.tqdm(*lowercase__      ,**lowercase__    )
   else:
    return EmptyTqdm(*lowercase__      ,**lowercase__    )






  def       SCREAMING_SNAKE_CASE   (   self     :  Tuple      ,*lowercase__     :  Any      ,**lowercase__     :  str    ):
   __lowercase													=				None
   if _tqdm_active:
    return tqdm_lib.tqdm.set_lock(*lowercase__      ,**lowercase__    )






  def       SCREAMING_SNAKE_CASE   (   self     :  Optional[Any]    ):
   if _tqdm_active:
    return tqdm_lib.tqdm.get_lock()
lowerCAmelCase__      		=			_tqdm_cls()


def 	_A  (					):






 """simple docstring"""



 global _tqdm_active
 return bool(_tqdm_active   )


def 	_A  (					):






 """simple docstring"""



 global _tqdm_active
 __lowercase													=				True






def 	_A  (					):






 """simple docstring"""



 global _tqdm_active
 __lowercase													=				False




'''simple docstring'''






import argparse

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


logging.set_verbosity_info()


def 	_A  (					A__  ,       A__  ,       A__   ):






 """simple docstring"""



 __lowercase													=				TaConfig.from_json_file(A__   )
 print(F"Building PyTorch model from configuration: {config}"   )
 __lowercase													=				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__      		=			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__      		=			parser.parse_args()
 convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path)

