
from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


SCREAMING_SNAKE_CASE							:str										=    logging.get_logger(__name__)

SCREAMING_SNAKE_CASE							:Optional[int]										=    {
    'microsoft/swin-tiny-patch4-window7-224': (
        'https://huggingface.co/microsoft/swin-tiny-patch4-window7-224/resolve/main/config.json'
    ),
    # See all Swin models at https://huggingface.co/models?filter=swin
}





class 							UpperCAmelCase				(  __SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE  ):




	'''simple docstring'''





	snake_case_    =					"swin"

	snake_case_    =					{
	    "num_attention_heads": "num_heads",
	    "num_hidden_layers": "num_layers",
	}






	def __init__(	self :			List[str]							,A :			Optional[int]=2_24							,A :			Any=4							,A :			Optional[int]=3							,A :			Optional[Any]=96							,A :			Tuple=[2, 2, 6, 2]							,A :			Any=[3, 6, 12, 24]							,A :			str=7							,A :			int=4.0							,A :			Dict=True							,A :			str=0.0							,A :			Union[str, Any]=0.0							,A :			Optional[Any]=0.1							,A :			Optional[int]="gelu"							,A :			Tuple=False							,A :			List[Any]=0.02							,A :			Any=1E-5							,A :			List[str]=32							,A :			List[Any]=None							,A :			List[str]=None							,**A :			Optional[int]							,):
					super().__init__(**A			)

					__A             =			image_size
					__A             =			patch_size
					__A             =			num_channels
					__A             =			embed_dim
					__A             =			depths
					__A             =			len(A			)
					__A             =			num_heads
					__A             =			window_size
					__A             =			mlp_ratio
					__A             =			qkv_bias
					__A             =			hidden_dropout_prob
					__A             =			attention_probs_dropout_prob
					__A             =			drop_path_rate
					__A             =			hidden_act
					__A             =			use_absolute_embeddings
					__A             =			layer_norm_eps
					__A             =			initializer_range
					__A             =			encoder_stride
					# we set the hidden_size attribute in order to make Swin work with VisionEncoderDecoderModel
					# this indicates the channel dimension after the last stage of the model
					__A             =			int(embed_dim * 2 ** (len(A			) - 1)			)
					__A             =			["stem"] + [f'''stage{idx}''' for idx in range(1							,len(A			) + 1			)]
					__A      ,							__A             =			get_aligned_output_features_output_indices(
					    out_features=A							,out_indices=A							,stage_names=self.stage_names			)





class 							UpperCAmelCase				(  __SCREAMING_SNAKE_CASE  ):




	'''simple docstring'''





	snake_case_    =					version.parse("1.11"  )






	@property
	def     UpperCamelCase_  (	self :			Optional[Any]			):
					return OrderedDict(
					    [
					        ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
					    ]			)







	@property
	def     UpperCamelCase_  (	self :			Tuple			):
					return 1E-4


import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import Audio, Features, Value
from .base import TaskTemplate





@dataclass(frozen=__SCREAMING_SNAKE_CASE  )
class 							UpperCAmelCase				(  __SCREAMING_SNAKE_CASE  ):




	'''simple docstring'''





	snake_case_    =					field(default="automatic-speech-recognition"      ,      metadata={"include_in_asdict_even_if_is_default": True}  )
	snake_case_    =					Features({"audio": Audio()}  )
	snake_case_    =					Features({"transcription": Value("string"  )}  )
	snake_case_    =					"audio"
	snake_case_    =					"transcription"






	def     UpperCamelCase_  (	self :			Optional[int]							,A :			Union[str, Any]			):
					if self.audio_column not in features:
									raise ValueError(f'''Column {self.audio_column} is not present in features.'''			)
					if not isinstance(features[self.audio_column]							,A			):
									raise ValueError(f'''Column {self.audio_column} is not an Audio type.'''			)
					__A             =			copy.deepcopy(self			)
					__A             =			self.input_schema.copy()
					__A             =			features[self.audio_column]
					__A             =			input_schema
					return task_template







	@property
	def     UpperCamelCase_  (	self :			int			):
					return {self.audio_column: "audio", self.transcription_column: "transcription"}
