

from math import ceil







def 			A_      (    _UpperCAmelCase				,	_UpperCAmelCase    ):
						SCREAMING_SNAKE_CASE_: Dict  		=       list(range(0				,	_UpperCAmelCase    )    )

						SCREAMING_SNAKE_CASE_: str  		=       [item for sublist in list(device_map.values()    ) for item in sublist]

						# Duplicate check
						SCREAMING_SNAKE_CASE_: List[str]  		=       []
						for i in device_map_blocks:
												if device_map_blocks.count(_UpperCAmelCase    ) > 1 and i not in duplicate_blocks:
																		duplicate_blocks.append(_UpperCAmelCase    )
    # Missing blocks
						SCREAMING_SNAKE_CASE_: Tuple  		=       [i for i in blocks if i not in device_map_blocks]
						SCREAMING_SNAKE_CASE_: Any  		=       [i for i in device_map_blocks if i not in blocks]

						if len(_UpperCAmelCase    ) != 0:
												raise ValueError(
												    "Duplicate attention blocks specified in device_map. Attention blocks must be specified to one device."
												    " These attention blocks were specified more than once: " + str(_UpperCAmelCase    )    )
						if len(_UpperCAmelCase    ) != 0:
												raise ValueError(
												    "There are attention blocks for this model that are not specified in the device_map. Add these attention "
												    "blocks to a device on the device_map: " + str(_UpperCAmelCase    )    )
						if len(_UpperCAmelCase    ) != 0:
												raise ValueError(
												    "The device_map contains more attention blocks than this model has. Remove these from the device_map:"
												    + str(_UpperCAmelCase    )    )







def 			A_      (    _UpperCAmelCase				,	_UpperCAmelCase    ):
						SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       list(range(_UpperCAmelCase    )    )
						SCREAMING_SNAKE_CASE_: Dict  		=       int(ceil(n_layers / len(_UpperCAmelCase    )    )    )
						SCREAMING_SNAKE_CASE_: List[str]  		=       [layers[i : i + n_blocks] for i in range(0				,	_UpperCAmelCase				,	_UpperCAmelCase    )]

						return dict(zip(_UpperCAmelCase				,	_UpperCAmelCase    )    )









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

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



@dataclass(frozen=UpperCAmelCase_	)
class   __lowercase				( UpperCAmelCase_	):




			"""simple docstring"""







			_UpperCAmelCase   :							str										=     field(default='''automatic-speech-recognition'''		,       metadata={'''include_in_asdict_even_if_is_default''': True}	)
			_UpperCAmelCase   :							ClassVar[Features]										=     Features({'''audio''': Audio()}	)
			_UpperCAmelCase   :							ClassVar[Features]										=     Features({'''transcription''': Value('''string'''	)}	)
			_UpperCAmelCase   :							str										=     "audio"
			_UpperCAmelCase   :							str										=     "transcription"



			def        _SCREAMING_SNAKE_CASE			( self  :     Optional[Any]   ,						lowerCAmelCase__  :     int):
									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]   ,						lowerCAmelCase__):
															raise ValueError(F"Column {self.audio_column} is not an Audio type.")
									SCREAMING_SNAKE_CASE_: Tuple  		=       copy.deepcopy(self)
									SCREAMING_SNAKE_CASE_: Optional[int]  		=       self.input_schema.copy()
									SCREAMING_SNAKE_CASE_: Dict  		=       features[self.audio_column]
									SCREAMING_SNAKE_CASE_: int  		=       input_schema
									return task_template




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






