
from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType





class 							UpperCAmelCase				(  __SCREAMING_SNAKE_CASE  ):




	'''simple docstring'''





	snake_case_    =					["image_processor", "tokenizer"]
	snake_case_    =					"BlipImageProcessor"
	snake_case_    =					("BertTokenizer", "BertTokenizerFast")






	def __init__(	self :			Dict							,A :			List[str]							,A :			Optional[Any]			):
					__A             =			False
					super().__init__(A							,A			)
					__A             =			self.image_processor






	def __call__(	self :			Any							,A :			ImageInput = None							,A :			Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None							,A :			bool = True							,A :			Union[bool, str, PaddingStrategy] = False							,A :			Union[bool, str, TruncationStrategy] = None							,A :			Optional[int] = None							,A :			int = 0							,A :			Optional[int] = None							,A :			Optional[bool] = None							,A :			bool = False							,A :			bool = False							,A :			bool = False							,A :			bool = False							,A :			bool = False							,A :			bool = True							,A :			Optional[Union[str, TensorType]] = None							,**A :			Optional[Any]							,):
					if images is None and text is None:
									raise ValueError("You have to specify either images or text."			)

					# Get only text
					if images is None:
									__A             =			self.tokenizer
									__A             =			self.tokenizer(
									    text=A							,add_special_tokens=A							,padding=A							,truncation=A							,max_length=A							,stride=A							,pad_to_multiple_of=A							,return_attention_mask=A							,return_overflowing_tokens=A							,return_special_tokens_mask=A							,return_offsets_mapping=A							,return_token_type_ids=A							,return_length=A							,verbose=A							,return_tensors=A							,**A							,)
									return text_encoding

					# add pixel_values
					__A             =			self.image_processor(A							,return_tensors=A			)

					if text is not None:
									__A             =			self.tokenizer(
									    text=A							,add_special_tokens=A							,padding=A							,truncation=A							,max_length=A							,stride=A							,pad_to_multiple_of=A							,return_attention_mask=A							,return_overflowing_tokens=A							,return_special_tokens_mask=A							,return_offsets_mapping=A							,return_token_type_ids=A							,return_length=A							,verbose=A							,return_tensors=A							,**A							,)
					else:
									__A             =			None

					if text_encoding is not None:
									encoding_image_processor.update(A			)

					return encoding_image_processor






	def     UpperCamelCase_  (	self :			Tuple							,*A :			Optional[int]							,**A :			Union[str, Any]			):
					return self.tokenizer.batch_decode(*A							,**A			)






	def     UpperCamelCase_  (	self :			Tuple							,*A :			int							,**A :			Dict			):
					return self.tokenizer.decode(*A							,**A			)







	@property
	def     UpperCamelCase_  (	self :			Any			):
					__A             =			self.tokenizer.model_input_names
					__A             =			self.image_processor.model_input_names
					return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names			)			)


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