


"""simple docstring"""
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      __A     (snake_case__):





							'''simple docstring'''

							__lowercase:		List[str]							      =    ["""image_processor""", """tokenizer"""]
							__lowercase:		List[Any]							      =    """BlipImageProcessor"""
							__lowercase:		Union[str, Any]							      =    ("""BertTokenizer""", """BertTokenizerFast""")



							def __init__(				self							:      Dict		,       UpperCAmelCase_							:      List[str]		,       UpperCAmelCase_							:      str       )					->Optional[Any]:



														"""simple docstring"""



														snake_case_           =		False
														super().__init__(UpperCAmelCase_		,       UpperCAmelCase_       )
														snake_case_           =		self.image_processor



							def __call__(				self							:      str		,       UpperCAmelCase_							:      ImageInput = None		,       UpperCAmelCase_							:      Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None		,       UpperCAmelCase_							:      bool = True		,       UpperCAmelCase_							:      Union[bool, str, PaddingStrategy] = False		,       UpperCAmelCase_							:      Union[bool, str, TruncationStrategy] = None		,       UpperCAmelCase_							:      Optional[int] = None		,       UpperCAmelCase_							:      int = 0		,       UpperCAmelCase_							:      Optional[int] = None		,       UpperCAmelCase_							:      Optional[bool] = None		,       UpperCAmelCase_							:      bool = False		,       UpperCAmelCase_							:      bool = False		,       UpperCAmelCase_							:      bool = False		,       UpperCAmelCase_							:      bool = False		,       UpperCAmelCase_							:      bool = False		,       UpperCAmelCase_							:      bool = True		,       UpperCAmelCase_							:      Optional[Union[str, TensorType]] = None		,       **UpperCAmelCase_							:      Tuple		,       )					->BatchEncoding:



														"""simple docstring"""



														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:
																					snake_case_           =		self.tokenizer
																					snake_case_           =		self.tokenizer(
																					    text=UpperCAmelCase_		,       add_special_tokens=UpperCAmelCase_		,       padding=UpperCAmelCase_		,       truncation=UpperCAmelCase_		,       max_length=UpperCAmelCase_		,       stride=UpperCAmelCase_		,       pad_to_multiple_of=UpperCAmelCase_		,       return_attention_mask=UpperCAmelCase_		,       return_overflowing_tokens=UpperCAmelCase_		,       return_special_tokens_mask=UpperCAmelCase_		,       return_offsets_mapping=UpperCAmelCase_		,       return_token_type_ids=UpperCAmelCase_		,       return_length=UpperCAmelCase_		,       verbose=UpperCAmelCase_		,       return_tensors=UpperCAmelCase_		,       **UpperCAmelCase_		,       )
																					return text_encoding

														# add pixel_values
														snake_case_           =		self.image_processor(UpperCAmelCase_		,       return_tensors=UpperCAmelCase_       )

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

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

														return encoding_image_processor



							def 		lowerCAmelCase       (				self							:      str		,       *UpperCAmelCase_							:      Optional[int]		,       **UpperCAmelCase_							:      Optional[Any]       )					->Optional[int]:



														"""simple docstring"""



														return self.tokenizer.batch_decode(*UpperCAmelCase_		,       **UpperCAmelCase_       )



							def 		lowerCAmelCase       (				self							:      int		,       *UpperCAmelCase_							:      Optional[Any]		,       **UpperCAmelCase_							:      str       )					->List[Any]:



														"""simple docstring"""



														return self.tokenizer.decode(*UpperCAmelCase_		,       **UpperCAmelCase_       )



							@property
							def 		lowerCAmelCase       (				self							:      List[Any]       )					->int:



														"""simple docstring"""



														snake_case_           =		self.tokenizer.model_input_names
														snake_case_           =		self.image_processor.model_input_names
														return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names       )       )







"""simple docstring"""
import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

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





@dataclass(frozen=snake_case__)
class      __A     (snake_case__):





							'''simple docstring'''

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



							def 		lowerCAmelCase       (				self							:      List[Any]		,       UpperCAmelCase_							:      Any       )					->int:



														"""simple docstring"""



														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]		,       UpperCAmelCase_       ):
																					raise ValueError(F"""Column {self.audio_column} is not an Audio type."""       )
														snake_case_           =		copy.deepcopy(self       )
														snake_case_           =		self.input_schema.copy()
														snake_case_           =		features[self.audio_column]
														snake_case_           =		input_schema
														return task_template



							@property
							def 		lowerCAmelCase       (				self							:      List[str]       )					->Dict[str, str]:



														"""simple docstring"""



														return {self.audio_column: "audio", self.transcription_column: "transcription"}



