



from ...configuration_utils import PretrainedConfig


__lowerCamelCase         =			{
    '''google/tapas-base-finetuned-sqa''': (
        '''https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json'''
    ),
    '''google/tapas-base-finetuned-wtq''': (
        '''https://huggingface.co/google/tapas-base-finetuned-wtq/resolve/main/config.json'''
    ),
    '''google/tapas-base-finetuned-wikisql-supervised''': (
        '''https://huggingface.co/google/tapas-base-finetuned-wikisql-supervised/resolve/main/config.json'''
    ),
    '''google/tapas-base-finetuned-tabfact''': (
        '''https://huggingface.co/google/tapas-base-finetuned-tabfact/resolve/main/config.json'''
    ),
}


class   snake_case_ (lowercase__  ):




       """simple docstring"""






       _lowerCamelCase			    =				"""tapas"""



       def __init__(     self     ,lowercase=30522     ,lowercase=768     ,lowercase=12     ,lowercase=12     ,lowercase=3072     ,lowercase="gelu"     ,lowercase=0.1     ,lowercase=0.1     ,lowercase=1024     ,lowercase=[3, 256, 256, 2, 256, 256, 10]     ,lowercase=0.02     ,lowercase=1E-12     ,lowercase=0     ,lowercase=10.0     ,lowercase=0     ,lowercase=1.0     ,lowercase=None     ,lowercase=1.0     ,lowercase=False     ,lowercase=None     ,lowercase=1.0     ,lowercase=1.0     ,lowercase=False     ,lowercase=False     ,lowercase="ratio"     ,lowercase=None     ,lowercase=None     ,lowercase=64     ,lowercase=32     ,lowercase=False     ,lowercase=True     ,lowercase=False     ,lowercase=False     ,lowercase=True     ,lowercase=False     ,lowercase=None     ,lowercase=None     ,**lowercase     ,):

             """simple docstring"""





             super().__init__(pad_token_id=lowercase     ,**lowercase)

             # BERT hyperparameters (with updated max_position_embeddings and type_vocab_sizes)
             UpperCAmelCase_  :	Optional[int]				      =		vocab_size
             UpperCAmelCase_  :	Any				      =		hidden_size
             UpperCAmelCase_  :	Any				      =		num_hidden_layers
             UpperCAmelCase_  :	Optional[Any]				      =		num_attention_heads
             UpperCAmelCase_  :	Dict				      =		hidden_act
             UpperCAmelCase_  :	int				      =		intermediate_size
             UpperCAmelCase_  :	List[str]				      =		hidden_dropout_prob
             UpperCAmelCase_  :	List[Any]				      =		attention_probs_dropout_prob
             UpperCAmelCase_  :	Union[str, Any]				      =		max_position_embeddings
             UpperCAmelCase_  :	str				      =		type_vocab_sizes
             UpperCAmelCase_  :	List[Any]				      =		initializer_range
             UpperCAmelCase_  :	int				      =		layer_norm_eps

             # Fine-tuning task hyperparameters
             UpperCAmelCase_  :	str				      =		positive_label_weight
             UpperCAmelCase_  :	Union[str, Any]				      =		num_aggregation_labels
             UpperCAmelCase_  :	List[Any]				      =		aggregation_loss_weight
             UpperCAmelCase_  :	Optional[Any]				      =		use_answer_as_supervision
             UpperCAmelCase_  :	Optional[Any]				      =		answer_loss_importance
             UpperCAmelCase_  :	Tuple				      =		use_normalized_answer_loss
             UpperCAmelCase_  :	Tuple				      =		huber_loss_delta
             UpperCAmelCase_  :	Dict				      =		temperature
             UpperCAmelCase_  :	Any				      =		aggregation_temperature
             UpperCAmelCase_  :	str				      =		use_gumbel_for_cells
             UpperCAmelCase_  :	List[Any]				      =		use_gumbel_for_aggregation
             UpperCAmelCase_  :	str				      =		average_approximation_function
             UpperCAmelCase_  :	List[Any]				      =		cell_selection_preference
             UpperCAmelCase_  :	List[str]				      =		answer_loss_cutoff
             UpperCAmelCase_  :	List[str]				      =		max_num_rows
             UpperCAmelCase_  :	int				      =		max_num_columns
             UpperCAmelCase_  :	str				      =		average_logits_per_cell
             UpperCAmelCase_  :	Tuple				      =		select_one_column
             UpperCAmelCase_  :	Tuple				      =		allow_empty_column_selection
             UpperCAmelCase_  :	Union[str, Any]				      =		init_cell_selection_weights_to_zero
             UpperCAmelCase_  :	Union[str, Any]				      =		reset_position_index_per_cell
             UpperCAmelCase_  :	str				      =		disable_per_token_loss

             # Aggregation hyperparameters
             UpperCAmelCase_  :	Union[str, Any]				      =		aggregation_labels
             UpperCAmelCase_  :	List[str]				      =		no_aggregation_label_index

             if isinstance(self.aggregation_labels     ,lowercase):
                   UpperCAmelCase_  :	Union[str, Any]				      =		{int(lowercase): v for k, v in aggregation_labels.items()}





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    _snake_case (       __snake_case					,  __snake_case					,  __snake_case					,  __snake_case    )     ->     Optional[Any]:






      '''simple docstring'''







      UpperCAmelCase_  :	List[str]				      =		FunnelConfig.from_json_file(__snake_case    )
      print(F"""Building PyTorch model from configuration: {config}"""    )
      UpperCAmelCase_  :	str				      =		FunnelBaseModel(__snake_case    ) if base_model else FunnelModel(__snake_case    )

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

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


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 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.'''
   )
   __lowerCamelCase         =			parser.parse_args()
   convert_tf_checkpoint_to_pytorch(
       args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path, args.base_model
   )
