





'''simple docstring'''




import functools
import operator

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


__SCREAMING_SNAKE_CASE     :Union[str, Any]       =				logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE     :Tuple       =				{
    '''asapp/sew-d-tiny-100k''': '''https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json''',
    # See all SEW-D models at https://huggingface.co/models?filter=sew-d
}







class   A_	(  lowerCAmelCase_			):
 _lowerCamelCase  : List[str]           =							"""sew-d"""




 def __init__(					self       :    Optional[Any]	,			snake_case_       :    Tuple=3_2	,			snake_case_       :    Optional[Any]=7_6_8	,			snake_case_       :    Tuple=1_2	,			snake_case_       :    Union[str, Any]=1_2	,			snake_case_       :    Tuple=3_0_7_2	,			snake_case_       :    Tuple=2	,			snake_case_       :    int=5_1_2	,			snake_case_       :    Optional[int]=2_5_6	,			snake_case_       :    Union[str, Any]=True	,			snake_case_       :    Any=True	,			snake_case_       :    str=("p2c", "c2p")	,			snake_case_       :    Dict="layer_norm"	,			snake_case_       :    str="gelu_python"	,			snake_case_       :    Dict=0.1	,			snake_case_       :    List[str]=0.1	,			snake_case_       :    Tuple=0.1	,			snake_case_       :    Any=0.0	,			snake_case_       :    Tuple=0.1	,			snake_case_       :    Union[str, Any]=0.0_2	,			snake_case_       :    str=1e-7	,			snake_case_       :    Optional[Any]=1e-5	,			snake_case_       :    Optional[Any]="group"	,			snake_case_       :    Tuple="gelu"	,			snake_case_       :    Tuple=(6_4, 1_2_8, 1_2_8, 1_2_8, 1_2_8, 2_5_6, 2_5_6, 2_5_6, 2_5_6, 5_1_2, 5_1_2, 5_1_2, 5_1_2)	,			snake_case_       :    Dict=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)	,			snake_case_       :    Dict=(1_0, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)	,			snake_case_       :    int=False	,			snake_case_       :    Union[str, Any]=1_2_8	,			snake_case_       :    int=1_6	,			snake_case_       :    Any=True	,			snake_case_       :    Tuple=0.0_5	,			snake_case_       :    Tuple=1_0	,			snake_case_       :    Dict=2	,			snake_case_       :    Tuple=0.0	,			snake_case_       :    List[Any]=1_0	,			snake_case_       :    Union[str, Any]=0	,			snake_case_       :    Any="mean"	,			snake_case_       :    Optional[Any]=False	,			snake_case_       :    Any=False	,			snake_case_       :    Tuple=2_5_6	,			snake_case_       :    int=0	,			snake_case_       :    Optional[Any]=1	,			snake_case_       :    List[str]=2	,			**snake_case_       :    List[str]	,			):
      super().__init__(**snake_case_	,			pad_token_id=snake_case_	,			bos_token_id=snake_case_	,			eos_token_id=snake_case_    )
      _UpperCAmelCase     							=   hidden_size
      _UpperCAmelCase     							=   feat_extract_norm
      _UpperCAmelCase     							=   feat_extract_activation
      _UpperCAmelCase     							=   list(snake_case_    )
      _UpperCAmelCase     							=   list(snake_case_    )
      _UpperCAmelCase     							=   list(snake_case_    )
      _UpperCAmelCase     							=   conv_bias
      _UpperCAmelCase     							=   num_conv_pos_embeddings
      _UpperCAmelCase     							=   num_conv_pos_embedding_groups
      _UpperCAmelCase     							=   len(self.conv_dim    )
      _UpperCAmelCase     							=   num_hidden_layers
      _UpperCAmelCase     							=   intermediate_size
      _UpperCAmelCase     							=   squeeze_factor
      _UpperCAmelCase     							=   max_position_embeddings
      _UpperCAmelCase     							=   position_buckets
      _UpperCAmelCase     							=   share_att_key
      _UpperCAmelCase     							=   relative_attention
      _UpperCAmelCase     							=   norm_rel_ebd
      _UpperCAmelCase     							=   list(snake_case_    )
      _UpperCAmelCase     							=   hidden_act
      _UpperCAmelCase     							=   num_attention_heads
      _UpperCAmelCase     							=   hidden_dropout
      _UpperCAmelCase     							=   attention_dropout
      _UpperCAmelCase     							=   activation_dropout
      _UpperCAmelCase     							=   feat_proj_dropout
      _UpperCAmelCase     							=   final_dropout
      _UpperCAmelCase     							=   layer_norm_eps
      _UpperCAmelCase     							=   feature_layer_norm_eps
      _UpperCAmelCase     							=   initializer_range
      _UpperCAmelCase     							=   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     							=   apply_spec_augment
      _UpperCAmelCase     							=   mask_time_prob
      _UpperCAmelCase     							=   mask_time_length
      _UpperCAmelCase     							=   mask_time_min_masks
      _UpperCAmelCase     							=   mask_feature_prob
      _UpperCAmelCase     							=   mask_feature_length
      _UpperCAmelCase     							=   mask_feature_min_masks

      # ctc loss
      _UpperCAmelCase     							=   ctc_loss_reduction
      _UpperCAmelCase     							=   ctc_zero_infinity

      # sequence classification
      _UpperCAmelCase     							=   use_weighted_layer_sum
      _UpperCAmelCase     							=   classifier_proj_size




 @property
 def      lowercase	(					self       :    Any    ):
      return functools.reduce(operator.mul	,			self.conv_stride	,			1    )








"""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 					__lowerCAmelCase					:


		'''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=__SCREAMING_SNAKE_CASE     ,			repr=__SCREAMING_SNAKE_CASE       )

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





		def 			__UpperCAmelCase       (  self      ):
				from .features import Value

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







@dataclass
class 					__lowerCAmelCase					:


		'''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=__SCREAMING_SNAKE_CASE     ,			repr=__SCREAMING_SNAKE_CASE       )

		def 			__UpperCAmelCase       (  self      ):
				__a           =			sorted(set(self.languages      )      ) if self.languages else None
				__a           =			len(self.languages      ) if self.languages else None

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

		def 			__UpperCAmelCase       (  self							, _a      ):
				__a           =			set(self.languages      )
				if self.languages and set(_a      ) - lang_set:
						raise ValueError(
						    f'''Some languages in example ({', '.join(sorted(set(_a      ) - lang_set      )      )}) are not in valid set ({', '.join(_a      )}).'''      )

				# 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(_a							, _a      ):
								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(_a      )      )

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





		def 			__UpperCAmelCase       (  self      ):
				from .features import Sequence, Value

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






