

from typing import Dict

from .base import GenericTensor, Pipeline



class   __lowercase				( UpperCAmelCase_	):




			"""simple docstring"""







			def        _SCREAMING_SNAKE_CASE			( self  :     str   ,						lowerCAmelCase__  :     int=None   ,						lowerCAmelCase__  :     Optional[int]=None   ,						lowerCAmelCase__  :     List[str]=None   ,						**lowerCAmelCase__  :     Optional[int]):
									if tokenize_kwargs is None:
															SCREAMING_SNAKE_CASE_: Any  		=       {}

									if truncation is not None:
															if "truncation" in tokenize_kwargs:
																					raise ValueError(
																					    "truncation parameter defined twice (given as keyword argument as well as in tokenize_kwargs)")
															SCREAMING_SNAKE_CASE_: Dict  		=       truncation

									SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       tokenize_kwargs

									SCREAMING_SNAKE_CASE_: List[Any]  		=       {}
									if return_tensors is not None:
															SCREAMING_SNAKE_CASE_: Any  		=       return_tensors

									return preprocess_params, {}, postprocess_params



			def        _SCREAMING_SNAKE_CASE			( self  :     Union[str, Any]   ,						lowerCAmelCase__  :     List[str]   ,						**lowerCAmelCase__  :     Tuple):
									SCREAMING_SNAKE_CASE_: Optional[Any]  		=       self.framework
									SCREAMING_SNAKE_CASE_: Any  		=       self.tokenizer(lowerCAmelCase__   ,						return_tensors=lowerCAmelCase__   ,						**lowerCAmelCase__)
									return model_inputs



			def        _SCREAMING_SNAKE_CASE			( self  :     Optional[int]   ,						lowerCAmelCase__  :     Any):
									SCREAMING_SNAKE_CASE_: int  		=       self.model(**lowerCAmelCase__)
									return model_outputs



			def        _SCREAMING_SNAKE_CASE			( self  :     Dict   ,						lowerCAmelCase__  :     Optional[Any]   ,						lowerCAmelCase__  :     Optional[Any]=False):
									# [0] is the first available tensor, logits or last_hidden_state.
									if return_tensors:
															return model_outputs[0]
									if self.framework == "pt":
															return model_outputs[0].tolist()
									elif self.framework == "tf":
															return model_outputs[0].numpy().tolist()




			def __call__( self  :     Union[str, Any]   ,						*lowerCAmelCase__  :     str   ,						**lowerCAmelCase__  :     Tuple):
									return super().__call__(*lowerCAmelCase__   ,						**lowerCAmelCase__)









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"}






