



'''simple docstring'''





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


_UpperCamelCase							    =						{
    'configuration_splinter': ['SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SplinterConfig'],
    'tokenization_splinter': ['SplinterTokenizer'],
}

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _UpperCamelCase							    =						['SplinterTokenizerFast']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _UpperCamelCase							    =						[
       'SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST',
       'SplinterForQuestionAnswering',
       'SplinterForPreTraining',
       'SplinterLayer',
       'SplinterModel',
       'SplinterPreTrainedModel',
   ]


if TYPE_CHECKING:
   from .configuration_splinter import SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP, SplinterConfig
   from .tokenization_splinter import SplinterTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_splinter_fast import SplinterTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_splinter import (
          SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST,
          SplinterForPreTraining,
          SplinterForQuestionAnswering,
          SplinterLayer,
          SplinterModel,
          SplinterPreTrainedModel,
      )


else:
   import sys

   _UpperCamelCase							    =						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)











'''simple docstring'''





import argparse

from transformers import CanineConfig, CanineModel, CanineTokenizer, load_tf_weights_in_canine
from transformers.utils import logging


logging.set_verbosity_info()

def 	a_					(							_lowerCAmelCase	,_lowerCAmelCase	)				->				List[Any]:
  # Initialize PyTorch model
  __lowerCamelCase	:	Union[str, Any]   	=			CanineConfig()
  __lowerCamelCase	:	Optional[Any]   	=			CanineModel(_lowerCAmelCase	)
  model.eval()

  print(F'Building PyTorch model from configuration: {config}'	)

  # Load weights from tf checkpoint
  load_tf_weights_in_canine(_lowerCAmelCase	,_lowerCAmelCase	,_lowerCAmelCase	)

  # Save pytorch-model (weights and configuration)
  print(F'Save PyTorch model to {pytorch_dump_path}'	)
  model.save_pretrained(_lowerCAmelCase	)

  # Save tokenizer files
  __lowerCamelCase	:	str   	=			CanineTokenizer()
  print(F'Save tokenizer files to {pytorch_dump_path}'	)
  tokenizer.save_pretrained(_lowerCAmelCase	)


if __name__ == "__main__":
   _UpperCamelCase							    =						argparse.ArgumentParser()
   # Required parameters
   parser.add_argument(
       '--tf_checkpoint_path',
       default=None,
       type=str,
       required=True,
       help='Path to the TensorFlow checkpoint. Should end with model.ckpt',
   )
   parser.add_argument(
       '--pytorch_dump_path',
       default=None,
       type=str,
       required=True,
       help='Path to a folder where the PyTorch model will be placed.',
   )
   _UpperCamelCase							    =						parser.parse_args()
   convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.pytorch_dump_path)






