




"""simple docstring"""

from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union

import pyarrow as pa


if TYPE_CHECKING:
       from .features import FeatureType





@dataclass
class 							lowercase_			:



 '''simple docstring'''
 UpperCAmelCase       :	List[str]
 UpperCAmelCase       :	Optional[str]     =      None
 # Automatically constructed
 UpperCAmelCase       :	ClassVar[str]     =      "dict"
 UpperCAmelCase       :	ClassVar[Any]     =      None
 UpperCAmelCase       :	str     =      field(default='''Translation'''     ,      init=__lowerCAmelCase     ,      repr=__lowerCAmelCase				)

 def __call__(					self			:			List[Any]						):
       return pa.struct({lang: pa.string() for lang in sorted(self.languages						)}						)



 def      lowerCAmelCase_				(					self			:			int						):
       from .features import Value

       return {k: Value('string'						) for k in sorted(self.languages						)}





@dataclass
class 							lowercase_			:



 '''simple docstring'''
 UpperCAmelCase       :	Optional[List]     =      None
 UpperCAmelCase       :	Optional[int]     =      None
 UpperCAmelCase       :	Optional[str]     =      None
 # Automatically constructed
 UpperCAmelCase       :	ClassVar[str]     =      "dict"
 UpperCAmelCase       :	ClassVar[Any]     =      None
 UpperCAmelCase       :	str     =      field(default='''TranslationVariableLanguages'''     ,      init=__lowerCAmelCase     ,      repr=__lowerCAmelCase				)

 def      lowerCAmelCase_				(					self			:			Tuple						):
       _A     =  sorted(set(self.languages						)						) if self.languages else None
       _A     =  len(self.languages						) if self.languages else None

 def __call__(					self			:			Tuple						):
       return pa.struct({'language': pa.list_(pa.string()						), 'translation': pa.list_(pa.string()						)}						)

 def      lowerCAmelCase_				(					self			:			str       ,				_UpperCAmelCase			:			Union[str, Any]						):
       _A     =  set(self.languages						)
       if self.languages and set(_UpperCAmelCase						) - lang_set:
             raise ValueError(
                 F'''Some languages in example ({", ".join(sorted(set(_UpperCAmelCase						) - lang_set						)						)}) are not in valid set ({", ".join(_UpperCAmelCase						)}).'''						)

       # Convert dictionary into tuples, splitting out cases where there are
       # multiple translations for a single language.
       _A     =  []
       for lang, text in translation_dict.items():
             if isinstance(_UpperCAmelCase       ,				_UpperCAmelCase						):
                   translation_tuples.append((lang, text)						)
             else:
                   translation_tuples.extend([(lang, el) for el in text]						)

        # Ensure translations are in ascending order by language code.
       _A  ,       _A     =  zip(*sorted(_UpperCAmelCase						)						)

       return {"language": languages, "translation": translations}



 def      lowerCAmelCase_				(					self			:			Optional[int]						):
       from .features import Sequence, Value

       return {
           "language": Sequence(Value('string'						)						),
           "translation": Sequence(Value('string'						)						),
       }







"""simple docstring"""

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


a							      =     logging.get_logger(__name__)

a							      =     {
    '''facebook/s2t-small-librispeech-asr''': (
        '''https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json'''
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech_to_text
}





class 							lowercase_			(	__lowerCAmelCase				):



 '''simple docstring'''
 UpperCAmelCase       :	str     =      '''speech_to_text'''
 UpperCAmelCase       :	List[Any]     =      ['''past_key_values''']
 UpperCAmelCase       :	Tuple     =      {'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}

 def __init__(					self			:			int       ,				_UpperCAmelCase			:			Union[str, Any]=10_000       ,				_UpperCAmelCase			:			Tuple=12       ,				_UpperCAmelCase			:			int=2_048       ,				_UpperCAmelCase			:			Optional[Any]=4       ,				_UpperCAmelCase			:			List[str]=6       ,				_UpperCAmelCase			:			Tuple=2_048       ,				_UpperCAmelCase			:			str=4       ,				_UpperCAmelCase			:			int=0.0       ,				_UpperCAmelCase			:			Dict=0.0       ,				_UpperCAmelCase			:			Optional[int]=True       ,				_UpperCAmelCase			:			Optional[Any]=True       ,				_UpperCAmelCase			:			Union[str, Any]="relu"       ,				_UpperCAmelCase			:			List[Any]=256       ,				_UpperCAmelCase			:			Optional[int]=0.1       ,				_UpperCAmelCase			:			Any=0.0       ,				_UpperCAmelCase			:			Dict=0.0       ,				_UpperCAmelCase			:			str=0.02       ,				_UpperCAmelCase			:			Any=2       ,				_UpperCAmelCase			:			Dict=True       ,				_UpperCAmelCase			:			List[str]=1       ,				_UpperCAmelCase			:			Tuple=0       ,				_UpperCAmelCase			:			Tuple=2       ,				_UpperCAmelCase			:			List[str]=6_000       ,				_UpperCAmelCase			:			Optional[Any]=1_024       ,				_UpperCAmelCase			:			Optional[Any]=2       ,				_UpperCAmelCase			:			Any=(5, 5)       ,				_UpperCAmelCase			:			int=1_024       ,				_UpperCAmelCase			:			str=80       ,				_UpperCAmelCase			:			Any=1       ,				**_UpperCAmelCase			:			Tuple       ,				):
       _A     =  vocab_size
       _A     =  d_model
       _A     =  encoder_ffn_dim
       _A     =  encoder_layers
       _A     =  encoder_attention_heads
       _A     =  decoder_ffn_dim
       _A     =  decoder_layers
       _A     =  decoder_attention_heads
       _A     =  dropout
       _A     =  attention_dropout
       _A     =  activation_dropout
       _A     =  activation_function
       _A     =  init_std
       _A     =  encoder_layerdrop
       _A     =  decoder_layerdrop
       _A     =  use_cache
       _A     =  encoder_layers
       _A     =  scale_embedding  # scale factor will be sqrt(d_model) if True
       _A     =  max_source_positions
       _A     =  max_target_positions
       _A     =  num_conv_layers
       _A     =  list(_UpperCAmelCase						)
       _A     =  conv_channels
       _A     =  input_feat_per_channel
       _A     =  input_channels

       if len(self.conv_kernel_sizes						) != self.num_conv_layers:
             raise ValueError(
                 'Configuration for convolutional module is incorrect. '
                 'It is required that `len(config.conv_kernel_sizes)` == `config.num_conv_layers` '
                 F'''but is `len(config.conv_kernel_sizes) = {len(self.conv_kernel_sizes						)}`, '''
                 F'''`config.num_conv_layers = {self.num_conv_layers}`.'''						)

       super().__init__(
           pad_token_id=_UpperCAmelCase       ,				bos_token_id=_UpperCAmelCase       ,				eos_token_id=_UpperCAmelCase       ,				is_encoder_decoder=_UpperCAmelCase       ,				decoder_start_token_id=_UpperCAmelCase       ,				**_UpperCAmelCase       ,				)

