



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       _SCREAMING_SNAKE_CASE	(UpperCamelCase ):
     lowerCAmelCase					=			"""tapas"""





     def __init__(       self :							int     ,  UpperCamelCase :							Tuple=3_0_5_2_2     ,  UpperCamelCase :							List[Any]=7_6_8     ,  UpperCamelCase :							Optional[int]=1_2     ,  UpperCamelCase :							Union[str, Any]=1_2     ,  UpperCamelCase :							Optional[int]=3_0_7_2     ,  UpperCamelCase :							int="gelu"     ,  UpperCamelCase :							List[Any]=0.1     ,  UpperCamelCase :							Union[str, Any]=0.1     ,  UpperCamelCase :							Dict=1_0_2_4     ,  UpperCamelCase :							Any=[3, 2_5_6, 2_5_6, 2, 2_5_6, 2_5_6, 1_0]     ,  UpperCamelCase :							int=0.0_2     ,  UpperCamelCase :							List[Any]=1E-12     ,  UpperCamelCase :							Optional[Any]=0     ,  UpperCamelCase :							Optional[int]=1_0.0     ,  UpperCamelCase :							Union[str, Any]=0     ,  UpperCamelCase :							Optional[int]=1.0     ,  UpperCamelCase :							Union[str, Any]=None     ,  UpperCamelCase :							Union[str, Any]=1.0     ,  UpperCamelCase :							Tuple=False     ,  UpperCamelCase :							Tuple=None     ,  UpperCamelCase :							Optional[Any]=1.0     ,  UpperCamelCase :							Optional[Any]=1.0     ,  UpperCamelCase :							List[str]=False     ,  UpperCamelCase :							Optional[int]=False     ,  UpperCamelCase :							Optional[Any]="ratio"     ,  UpperCamelCase :							Tuple=None     ,  UpperCamelCase :							Any=None     ,  UpperCamelCase :							str=6_4     ,  UpperCamelCase :							List[str]=3_2     ,  UpperCamelCase :							str=False     ,  UpperCamelCase :							Dict=True     ,  UpperCamelCase :							Any=False     ,  UpperCamelCase :							int=False     ,  UpperCamelCase :							Dict=True     ,  UpperCamelCase :							List[str]=False     ,  UpperCamelCase :							str=None     ,  UpperCamelCase :							Optional[Any]=None     ,  **UpperCamelCase :							List[str]     ,  )->Dict:
      super().__init__(pad_token_id=UpperCamelCase     ,  **UpperCamelCase				)

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

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

      # Aggregation hyperparameters
      __SCREAMING_SNAKE_CASE       :    Dict       =	aggregation_labels
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	no_aggregation_label_index

      if isinstance(self.aggregation_labels     ,  UpperCamelCase				):
       __SCREAMING_SNAKE_CASE       :    List[str]       =	{int(UpperCamelCase				): v for k, v in aggregation_labels.items()}











# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ..models.auto import AutoModelForSeqaSeqLM, AutoTokenizer
from .base import PipelineTool

class       _SCREAMING_SNAKE_CASE	(UpperCamelCase ):
     lowerCAmelCase					=			"""philschmid/bart-large-cnn-samsum"""
     lowerCAmelCase					=			(
         """This is a tool that summarizes an English text. It takes an input `text` containing the text to summarize, """
         """and returns a summary of the text."""
     )
     lowerCAmelCase					=			"""summarizer"""
     lowerCAmelCase					=			AutoTokenizer
     lowerCAmelCase					=			AutoModelForSeqaSeqLM

     lowerCAmelCase					=			["""text"""]
     lowerCAmelCase					=			["""text"""]





     def 	__snake_case    (       self :							Union[str, Any]     ,  UpperCamelCase :							Tuple				)->Tuple:
      return self.pre_processor(UpperCamelCase     ,  return_tensors="pt"     ,  truncation=UpperCamelCase				)





     def 	__snake_case    (       self :							Dict     ,  UpperCamelCase :							List[Any]				)->Optional[Any]:
      return self.model.generate(**UpperCamelCase				)[0]






     def 	__snake_case    (       self :							Tuple     ,  UpperCamelCase :							Dict				)->Optional[int]:
      return self.pre_processor.decode(UpperCamelCase     ,  skip_special_tokens=UpperCamelCase     ,  clean_up_tokenization_spaces=UpperCamelCase				)






