






import functools
import operator

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


SCREAMING_SNAKE_CASE 							=						logging.get_logger(__name__)

SCREAMING_SNAKE_CASE 							=						{
    'asapp/sew-tiny-100k': 'https://huggingface.co/asapp/sew-tiny-100k/resolve/main/config.json',
    # See all SEW models at https://huggingface.co/models?filter=sew
}
class 							A_    (						__lowercase			):






 '''simple docstring'''




 _SCREAMING_SNAKE_CASE							:			List[Any] =					"sew"


 def __init__(	self							,  _A=32							,  _A=768							,  _A=12							,  _A=12							,  _A=3072							,  _A=2							,  _A="gelu"							,  _A=0.1							,  _A=0.1							,  _A=0.1							,  _A=0.0							,  _A=0.1							,  _A=0.1							,  _A=0.02							,  _A=1e-5							,  _A="group"							,  _A="gelu"							,  _A=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)							,  _A=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)							,  _A=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)							,  _A=False							,  _A=128							,  _A=16							,  _A=True							,  _A=0.05							,  _A=10							,  _A=2							,  _A=0.0							,  _A=10							,  _A=0							,  _A="mean"							,  _A=False							,  _A=False							,  _A=256							,  _A=0							,  _A=1							,  _A=2							,  **_A							,  ) ->		Optional[Any]:

     """simple docstring"""



     super().__init__(**_A							,  pad_token_id=_A							,  bos_token_id=_A							,  eos_token_id=_A)
     _UpperCAmelCase				:      Dict			  =				hidden_size
     _UpperCAmelCase				:      Optional[int]			  =				feat_extract_norm
     _UpperCAmelCase				:      Optional[Any]			  =				feat_extract_activation
     _UpperCAmelCase				:      int			  =				list(_A)
     _UpperCAmelCase				:      Optional[Any]			  =				list(_A)
     _UpperCAmelCase				:      List[str]			  =				list(_A)
     _UpperCAmelCase				:      Union[str, Any]			  =				conv_bias
     _UpperCAmelCase				:      Tuple			  =				num_conv_pos_embeddings
     _UpperCAmelCase				:      Optional[Any]			  =				num_conv_pos_embedding_groups
     _UpperCAmelCase				:      str			  =				len(self.conv_dim)
     _UpperCAmelCase				:      Dict			  =				num_hidden_layers
     _UpperCAmelCase				:      Dict			  =				intermediate_size
     _UpperCAmelCase				:      List[Any]			  =				squeeze_factor
     _UpperCAmelCase				:      str			  =				hidden_act
     _UpperCAmelCase				:      Optional[int]			  =				num_attention_heads
     _UpperCAmelCase				:      List[str]			  =				hidden_dropout
     _UpperCAmelCase				:      Any			  =				attention_dropout
     _UpperCAmelCase				:      List[Any]			  =				activation_dropout
     _UpperCAmelCase				:      Dict			  =				feat_proj_dropout
     _UpperCAmelCase				:      List[str]			  =				final_dropout
     _UpperCAmelCase				:      Optional[int]			  =				layerdrop
     _UpperCAmelCase				:      List[str]			  =				layer_norm_eps
     _UpperCAmelCase				:      Any			  =				initializer_range
     _UpperCAmelCase				:      Union[str, Any]			  =				vocab_size

     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)`,'''
             f'''but is `len(config.conv_dim) = {len(self.conv_dim)}`, `len(config.conv_stride)'''
             f'''= {len(self.conv_stride)}`, `len(config.conv_kernel) = {len(self.conv_kernel)}`.''')

     # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
     _UpperCAmelCase				:      Tuple			  =				apply_spec_augment
     _UpperCAmelCase				:      List[str]			  =				mask_time_prob
     _UpperCAmelCase				:      int			  =				mask_time_length
     _UpperCAmelCase				:      Any			  =				mask_time_min_masks
     _UpperCAmelCase				:      Dict			  =				mask_feature_prob
     _UpperCAmelCase				:      Optional[Any]			  =				mask_feature_length
     _UpperCAmelCase				:      Optional[Any]			  =				mask_feature_min_masks

     # ctc loss
     _UpperCAmelCase				:      str			  =				ctc_loss_reduction
     _UpperCAmelCase				:      Optional[int]			  =				ctc_zero_infinity

     # sequence classification
     _UpperCAmelCase				:      Optional[int]			  =				use_weighted_layer_sum
     _UpperCAmelCase				:      str			  =				classifier_proj_size


 @property
 def  snake_case__				(	self) ->		str:

     """simple docstring"""



     return functools.reduce(operator.mul							,  self.conv_stride							,  1)












import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


SCREAMING_SNAKE_CASE 							=						'\nHugging 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.\n\nIn March 2021, Hugging Face raised $40 million in a Series B funding round.[3]\n\nOn 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]\n'
class 							A_    (						unittest.TestCase ,   __lowercase			):






 '''simple docstring'''




 def  snake_case__				(	self) ->		int:

     """simple docstring"""



     _UpperCAmelCase				:      int			  =				load_tool('''text-question-answering''')
     self.tool.setup()
     _UpperCAmelCase				:      Any			  =				load_tool('''text-question-answering'''							,  remote=_A)


 def  snake_case__				(	self) ->		Union[str, Any]:

     """simple docstring"""



     _UpperCAmelCase				:      Optional[Any]			  =				self.tool(_A							,  '''What did Hugging Face do in April 2021?''')
     self.assertEqual(_A							,  '''launched the BigScience Research Workshop''')


 def  snake_case__				(	self) ->		str:

     """simple docstring"""



     _UpperCAmelCase				:      str			  =				self.remote_tool(_A							,  '''What did Hugging Face do in April 2021?''')
     self.assertEqual(_A							,  '''launched the BigScience Research Workshop''')


 def  snake_case__				(	self) ->		Optional[int]:

     """simple docstring"""



     _UpperCAmelCase				:      Dict			  =				self.tool(text=_A							,  question='''What did Hugging Face do in April 2021?''')
     self.assertEqual(_A							,  '''launched the BigScience Research Workshop''')


 def  snake_case__				(	self) ->		Dict:

     """simple docstring"""



     _UpperCAmelCase				:      Optional[int]			  =				self.remote_tool(text=_A							,  question='''What did Hugging Face do in April 2021?''')
     self.assertEqual(_A							,  '''launched the BigScience Research Workshop''')




