


from ...configuration_utils import PretrainedConfig


_A			=						{
    '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    UpperCAmelCase__	( __UpperCamelCase		):



     """simple docstring"""






     UpperCAmelCase__						:		Optional[Any]              =  "tapas"






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

          # BERT hyperparameters (with updated max_position_embeddings and type_vocab_sizes)
          __UpperCamelCase   							=vocab_size
          __UpperCamelCase   							=hidden_size
          __UpperCamelCase   							=num_hidden_layers
          __UpperCamelCase   							=num_attention_heads
          __UpperCamelCase   							=hidden_act
          __UpperCamelCase   							=intermediate_size
          __UpperCamelCase   							=hidden_dropout_prob
          __UpperCamelCase   							=attention_probs_dropout_prob
          __UpperCamelCase   							=max_position_embeddings
          __UpperCamelCase   							=type_vocab_sizes
          __UpperCamelCase   							=initializer_range
          __UpperCamelCase   							=layer_norm_eps

          # Fine-tuning task hyperparameters
          __UpperCamelCase   							=positive_label_weight
          __UpperCamelCase   							=num_aggregation_labels
          __UpperCamelCase   							=aggregation_loss_weight
          __UpperCamelCase   							=use_answer_as_supervision
          __UpperCamelCase   							=answer_loss_importance
          __UpperCamelCase   							=use_normalized_answer_loss
          __UpperCamelCase   							=huber_loss_delta
          __UpperCamelCase   							=temperature
          __UpperCamelCase   							=aggregation_temperature
          __UpperCamelCase   							=use_gumbel_for_cells
          __UpperCamelCase   							=use_gumbel_for_aggregation
          __UpperCamelCase   							=average_approximation_function
          __UpperCamelCase   							=cell_selection_preference
          __UpperCamelCase   							=answer_loss_cutoff
          __UpperCamelCase   							=max_num_rows
          __UpperCamelCase   							=max_num_columns
          __UpperCamelCase   							=average_logits_per_cell
          __UpperCamelCase   							=select_one_column
          __UpperCamelCase   							=allow_empty_column_selection
          __UpperCamelCase   							=init_cell_selection_weights_to_zero
          __UpperCamelCase   							=reset_position_index_per_cell
          __UpperCamelCase   							=disable_per_token_loss

          # Aggregation hyperparameters
          __UpperCamelCase   							=aggregation_labels
          __UpperCamelCase   							=no_aggregation_label_index

          if isinstance(self.aggregation_labels ,       _lowerCAmelCase   ):
               __UpperCamelCase   							={int(_lowerCAmelCase   ): v for k, v in aggregation_labels.items()}









import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin






class    UpperCAmelCase__	( A_		):



    """simple docstring"""






    UpperCAmelCase__						:		Optional[int]              =  "MCTCTFeatureExtractor"
    UpperCAmelCase__						:		str              =  "AutoTokenizer"






    def __init__(      self ,       A_ ,       A_   )  ->	Dict:
         super().__init__(A_ ,       A_   )
         __UpperCamelCase   							=self.feature_extractor
         __UpperCamelCase   							=False






    def __call__(      self ,       *A_ ,       **A_   )  ->	Optional[Any]:
         # For backward compatibility
         if self._in_target_context_manager:
              return self.current_processor(*A_ ,       **A_   )

         if "raw_speech" in kwargs:
              warnings.warn('Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.'   )
              __UpperCamelCase   							=kwargs.pop('raw_speech'   )
         else:
              __UpperCamelCase   							=kwargs.pop('audio' ,       A_   )
         __UpperCamelCase   							=kwargs.pop('sampling_rate' ,       A_   )
         __UpperCamelCase   							=kwargs.pop('text' ,       A_   )
         if len(A_   ) > 0:
              __UpperCamelCase   							=args[0]
              __UpperCamelCase   							=args[1:]

         if audio is None and text is None:
              raise ValueError('You need to specify either an `audio` or `text` input to process.'   )

         if audio is not None:
              __UpperCamelCase   							=self.feature_extractor(A_ ,       *A_ ,       sampling_rate=A_ ,       **A_   )
         if text is not None:
              __UpperCamelCase   							=self.tokenizer(A_ ,       **A_   )

         if text is None:
              return inputs
         elif audio is None:
              return encodings
         else:
              __UpperCamelCase   							=encodings['input_ids']
              return inputs






    def _a (      self ,       *A_ ,       **A_   )  ->	str:
         return self.tokenizer.batch_decode(*A_ ,       **A_   )






    def _a (      self ,       *A_ ,       **A_   )  ->	List[Any]:
         # For backward compatibility
         if self._in_target_context_manager:
              return self.current_processor.pad(*A_ ,       **A_   )

         __UpperCamelCase   							=kwargs.pop('input_features' ,       A_   )
         __UpperCamelCase   							=kwargs.pop('labels' ,       A_   )
         if len(A_   ) > 0:
              __UpperCamelCase   							=args[0]
              __UpperCamelCase   							=args[1:]

         if input_features is not None:
              __UpperCamelCase   							=self.feature_extractor.pad(A_ ,       *A_ ,       **A_   )
         if labels is not None:
              __UpperCamelCase   							=self.tokenizer.pad(A_ ,       **A_   )

         if labels is None:
              return input_features
         elif input_features is None:
              return labels
         else:
              __UpperCamelCase   							=labels['input_ids']
              return input_features






    def _a (      self ,       *A_ ,       **A_   )  ->	Optional[int]:
         return self.tokenizer.decode(*A_ ,       **A_   )






    @contextmanager
    def _a (      self   )  ->	str:
         warnings.warn(
             '`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '
             'labels by using the argument `text` of the regular `__call__` method (either in the same call as '
             'your audio inputs, or in a separate call.'   )
         __UpperCamelCase   							=True
         __UpperCamelCase   							=self.tokenizer
         yield
         __UpperCamelCase   							=self.feature_extractor
         __UpperCamelCase   							=False





