






"""simple docstring"""





import functools
import operator

from ...configuration_utils import PretrainedConfig
from ...utils import logging


_SCREAMING_SNAKE_CASE					:				Optional[int]					    =						logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE					:				Union[str, Any]					    =						{
    '''facebook/wav2vec2-base-960h''': '''https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json''',
    # See all Wav2Vec2 models at https://huggingface.co/models?filter=wav2vec2
}






class      a						(					__snake_case		):
    SCREAMING_SNAKE_CASE						:     Optional[int]						= """wav2vec2"""






    def __init__(       self     :							Dict       ,						__SCREAMING_SNAKE_CASE     :							List[str]=32       ,						__SCREAMING_SNAKE_CASE     :							Optional[Any]=768       ,						__SCREAMING_SNAKE_CASE     :							Tuple=12       ,						__SCREAMING_SNAKE_CASE     :							Optional[Any]=12       ,						__SCREAMING_SNAKE_CASE     :							str=3072       ,						__SCREAMING_SNAKE_CASE     :							List[str]="gelu"       ,						__SCREAMING_SNAKE_CASE     :							Optional[Any]=0.1       ,						__SCREAMING_SNAKE_CASE     :							str=0.1       ,						__SCREAMING_SNAKE_CASE     :							Optional[Any]=0.1       ,						__SCREAMING_SNAKE_CASE     :							List[str]=0.0       ,						__SCREAMING_SNAKE_CASE     :							Optional[int]=0.0       ,						__SCREAMING_SNAKE_CASE     :							int=0.1       ,						__SCREAMING_SNAKE_CASE     :							List[str]=0.1       ,						__SCREAMING_SNAKE_CASE     :							Union[str, Any]=0.02       ,						__SCREAMING_SNAKE_CASE     :							int=1e-5       ,						__SCREAMING_SNAKE_CASE     :							List[Any]="group"       ,						__SCREAMING_SNAKE_CASE     :							Any="gelu"       ,						__SCREAMING_SNAKE_CASE     :							List[str]=(512, 512, 512, 512, 512, 512, 512)       ,						__SCREAMING_SNAKE_CASE     :							Dict=(5, 2, 2, 2, 2, 2, 2)       ,						__SCREAMING_SNAKE_CASE     :							Optional[int]=(10, 3, 3, 3, 3, 2, 2)       ,						__SCREAMING_SNAKE_CASE     :							Tuple=False       ,						__SCREAMING_SNAKE_CASE     :							Optional[int]=128       ,						__SCREAMING_SNAKE_CASE     :							List[Any]=16       ,						__SCREAMING_SNAKE_CASE     :							Dict=False       ,						__SCREAMING_SNAKE_CASE     :							List[Any]=True       ,						__SCREAMING_SNAKE_CASE     :							Optional[Any]=0.05       ,						__SCREAMING_SNAKE_CASE     :							Any=10       ,						__SCREAMING_SNAKE_CASE     :							Dict=2       ,						__SCREAMING_SNAKE_CASE     :							Optional[int]=0.0       ,						__SCREAMING_SNAKE_CASE     :							Dict=10       ,						__SCREAMING_SNAKE_CASE     :							str=0       ,						__SCREAMING_SNAKE_CASE     :							Tuple=320       ,						__SCREAMING_SNAKE_CASE     :							List[Any]=2       ,						__SCREAMING_SNAKE_CASE     :							str=0.1       ,						__SCREAMING_SNAKE_CASE     :							str=100       ,						__SCREAMING_SNAKE_CASE     :							List[str]=256       ,						__SCREAMING_SNAKE_CASE     :							Union[str, Any]=256       ,						__SCREAMING_SNAKE_CASE     :							int=0.1       ,						__SCREAMING_SNAKE_CASE     :							List[str]="sum"       ,						__SCREAMING_SNAKE_CASE     :							List[str]=False       ,						__SCREAMING_SNAKE_CASE     :							Union[str, Any]=False       ,						__SCREAMING_SNAKE_CASE     :							Any=256       ,						__SCREAMING_SNAKE_CASE     :							int=(512, 512, 512, 512, 1500)       ,						__SCREAMING_SNAKE_CASE     :							str=(5, 3, 3, 1, 1)       ,						__SCREAMING_SNAKE_CASE     :							Union[str, Any]=(1, 2, 3, 1, 1)       ,						__SCREAMING_SNAKE_CASE     :							List[str]=512       ,						__SCREAMING_SNAKE_CASE     :							Union[str, Any]=0       ,						__SCREAMING_SNAKE_CASE     :							Any=1       ,						__SCREAMING_SNAKE_CASE     :							str=2       ,						__SCREAMING_SNAKE_CASE     :							Union[str, Any]=False       ,						__SCREAMING_SNAKE_CASE     :							str=3       ,						__SCREAMING_SNAKE_CASE     :							Dict=2       ,						__SCREAMING_SNAKE_CASE     :							List[str]=3       ,						__SCREAMING_SNAKE_CASE     :							Tuple=None       ,						__SCREAMING_SNAKE_CASE     :							Any=None       ,						**__SCREAMING_SNAKE_CASE     :							Dict       ,						)     ->		List[str]:
      super().__init__(**__SCREAMING_SNAKE_CASE       ,						pad_token_id=__SCREAMING_SNAKE_CASE       ,						bos_token_id=__SCREAMING_SNAKE_CASE       ,						eos_token_id=__SCREAMING_SNAKE_CASE					)
      lowerCamelCase_         =						hidden_size
      lowerCamelCase_         =						feat_extract_norm
      lowerCamelCase_         =						feat_extract_activation
      lowerCamelCase_         =						list(__SCREAMING_SNAKE_CASE					)
      lowerCamelCase_         =						list(__SCREAMING_SNAKE_CASE					)
      lowerCamelCase_         =						list(__SCREAMING_SNAKE_CASE					)
      lowerCamelCase_         =						conv_bias
      lowerCamelCase_         =						num_conv_pos_embeddings
      lowerCamelCase_         =						num_conv_pos_embedding_groups
      lowerCamelCase_         =						len(self.conv_dim					)
      lowerCamelCase_         =						num_hidden_layers
      lowerCamelCase_         =						intermediate_size
      lowerCamelCase_         =						hidden_act
      lowerCamelCase_         =						num_attention_heads
      lowerCamelCase_         =						hidden_dropout
      lowerCamelCase_         =						attention_dropout
      lowerCamelCase_         =						activation_dropout
      lowerCamelCase_         =						feat_proj_dropout
      lowerCamelCase_         =						final_dropout
      lowerCamelCase_         =						layerdrop
      lowerCamelCase_         =						layer_norm_eps
      lowerCamelCase_         =						initializer_range
      lowerCamelCase_         =						vocab_size
      lowerCamelCase_         =						do_stable_layer_norm
      lowerCamelCase_         =						use_weighted_layer_sum

      if (
          (len(self.conv_stride					) != self.num_feat_extract_layers)
          or (len(self.conv_kernel					) != self.num_feat_extract_layers)
          or (len(self.conv_dim					) != self.num_feat_extract_layers)
      ):
        raise ValueError(
            'Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =='
            ' `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ='
            F''' {len(self.conv_dim					)}`, `len(config.conv_stride) = {len(self.conv_stride					)}`,'''
            F''' `len(config.conv_kernel) = {len(self.conv_kernel					)}`.'''					)

      # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
      lowerCamelCase_         =						apply_spec_augment
      lowerCamelCase_         =						mask_time_prob
      lowerCamelCase_         =						mask_time_length
      lowerCamelCase_         =						mask_time_min_masks
      lowerCamelCase_         =						mask_feature_prob
      lowerCamelCase_         =						mask_feature_length
      lowerCamelCase_         =						mask_feature_min_masks

      # parameters for pretraining with codevector quantized representations
      lowerCamelCase_         =						num_codevectors_per_group
      lowerCamelCase_         =						num_codevector_groups
      lowerCamelCase_         =						contrastive_logits_temperature
      lowerCamelCase_         =						feat_quantizer_dropout
      lowerCamelCase_         =						num_negatives
      lowerCamelCase_         =						codevector_dim
      lowerCamelCase_         =						proj_codevector_dim
      lowerCamelCase_         =						diversity_loss_weight

      # ctc loss
      lowerCamelCase_         =						ctc_loss_reduction
      lowerCamelCase_         =						ctc_zero_infinity

      # adapter
      lowerCamelCase_         =						add_adapter
      lowerCamelCase_         =						adapter_kernel_size
      lowerCamelCase_         =						adapter_stride
      lowerCamelCase_         =						num_adapter_layers
      lowerCamelCase_         =						output_hidden_size or hidden_size
      lowerCamelCase_         =						adapter_attn_dim

      # SequenceClassification-specific parameter. Feel free to ignore for other classes.
      lowerCamelCase_         =						classifier_proj_size

      # XVector-specific parameters. Feel free to ignore for other classes.
      lowerCamelCase_         =						list(__SCREAMING_SNAKE_CASE					)
      lowerCamelCase_         =						list(__SCREAMING_SNAKE_CASE					)
      lowerCamelCase_         =						list(__SCREAMING_SNAKE_CASE					)
      lowerCamelCase_         =						xvector_output_dim






    @property
    def    UpperCamelCase       (       self     :							Optional[Any]					)     ->		str:
      return functools.reduce(operator.mul       ,						self.conv_stride       ,						1					)












"""simple docstring"""





import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


_SCREAMING_SNAKE_CASE					:				Optional[int]					    =						'''
Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenagers.[2] After open-sourcing the model behind the chatbot, the company pivoted to focus on being a platform for machine learning.

In March 2021, Hugging Face raised $40 million in a Series B funding round.[3]

On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model.[4] In 2022, the workshop concluded with the announcement of BLOOM, a multilingual large language model with 176 billion parameters.[5]
'''






class      a						(					unittest.TestCase  ,      __snake_case		):






    def    UpperCamelCase       (       self     :							int					)     ->		Optional[int]:
      lowerCamelCase_         =						load_tool('text-question-answering'					)
      self.tool.setup()
      lowerCamelCase_         =						load_tool('text-question-answering'       ,						remote=__SCREAMING_SNAKE_CASE					)






    def    UpperCamelCase       (       self     :							Dict					)     ->		Tuple:
      lowerCamelCase_         =						self.tool(__SCREAMING_SNAKE_CASE       ,						'What did Hugging Face do in April 2021?'					)
      self.assertEqual(__SCREAMING_SNAKE_CASE       ,						'launched the BigScience Research Workshop'					)






    def    UpperCamelCase       (       self     :							List[Any]					)     ->		Optional[int]:
      lowerCamelCase_         =						self.remote_tool(__SCREAMING_SNAKE_CASE       ,						'What did Hugging Face do in April 2021?'					)
      self.assertEqual(__SCREAMING_SNAKE_CASE       ,						'launched the BigScience Research Workshop'					)






    def    UpperCamelCase       (       self     :							List[str]					)     ->		Optional[int]:
      lowerCamelCase_         =						self.tool(text=__SCREAMING_SNAKE_CASE       ,						question='What did Hugging Face do in April 2021?'					)
      self.assertEqual(__SCREAMING_SNAKE_CASE       ,						'launched the BigScience Research Workshop'					)






    def    UpperCamelCase       (       self     :							Union[str, Any]					)     ->		int:
      lowerCamelCase_         =						self.remote_tool(text=__SCREAMING_SNAKE_CASE       ,						question='What did Hugging Face do in April 2021?'					)
      self.assertEqual(__SCREAMING_SNAKE_CASE       ,						'launched the BigScience Research Workshop'					)




