






'''simple docstring'''

import warnings
from typing import List, Optional, Union

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







class 	SCREAMING_SNAKE_CASE	(      lowerCAmelCase_  ):
       snake_case__    :     Dict   		=			['image_processor', 'tokenizer']
       snake_case__    :     Any   		=			'ViltImageProcessor'
       snake_case__    :     str   		=			('BertTokenizer', 'BertTokenizerFast')




       def __init__(					self      : int	,    A__      : List[str]=None	,    A__      : Dict=None	,    **A__      : Optional[int]					):


            """simple docstring"""







            __lowerCamelCase						:       List[str]				   =				None
            if "feature_extractor" in kwargs:
                 warnings.warn(
                     """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
                     """ instead."""	,    A__	,    )
                 __lowerCamelCase						:       Any				   =				kwargs.pop("""feature_extractor"""					)

            __lowerCamelCase						:       Union[str, Any]				   =				image_processor if image_processor is not None else feature_extractor
            if image_processor is None:
                 raise ValueError("""You need to specify an `image_processor`."""					)
            if tokenizer is None:
                 raise ValueError("""You need to specify a `tokenizer`."""					)

            super().__init__(A__	,    A__					)
            __lowerCamelCase						:       str				   =				self.image_processor




       def __call__(					self      : List[Any]	,    A__      : Any	,    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__      : Optional[bool] = None	,    A__      : bool = False	,    A__      : bool = False	,    A__      : bool = False	,    A__      : bool = False	,    A__      : bool = True	,    A__      : Optional[Union[str, TensorType]] = None	,    **A__      : Tuple	,    ):


            """simple docstring"""







            __lowerCamelCase						:       List[str]				   =				self.tokenizer(
                text=A__	,    add_special_tokens=A__	,    padding=A__	,    truncation=A__	,    max_length=A__	,    stride=A__	,    pad_to_multiple_of=A__	,    return_token_type_ids=A__	,    return_attention_mask=A__	,    return_overflowing_tokens=A__	,    return_special_tokens_mask=A__	,    return_offsets_mapping=A__	,    return_length=A__	,    verbose=A__	,    return_tensors=A__	,    **A__	,    )
            # add pixel_values + pixel_mask
            __lowerCamelCase						:       List[Any]				   =				self.image_processor(A__	,    return_tensors=A__					)
            encoding.update(A__					)

            return encoding




       def 					a_					(					self      : List[Any]	,    *A__      : Optional[int]	,    **A__      : List[Any]					):


            """simple docstring"""







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




       def 					a_					(					self      : str	,    *A__      : Optional[int]	,    **A__      : Dict					):


            """simple docstring"""







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




       @property
       def 					a_					(					self      : Optional[Any]					):


            """simple docstring"""







            __lowerCamelCase						:       Tuple				   =				self.tokenizer.model_input_names
            __lowerCamelCase						:       Optional[int]				   =				self.image_processor.model_input_names
            return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names					)					)




       @property
       def 					a_					(					self      : int					):


            """simple docstring"""







            warnings.warn(
                """`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."""	,    A__	,    )
            return self.image_processor_class




       @property
       def 					a_					(					self      : List[str]					):


            """simple docstring"""







            warnings.warn(
                """`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."""	,    A__	,    )
            return self.image_processor











'''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=lowerCAmelCase_  )
class 	SCREAMING_SNAKE_CASE	(      lowerCAmelCase_  ):
       snake_case__    :     str   		=			field(default='automatic-speech-recognition'    ,   metadata={'include_in_asdict_even_if_is_default': True}  )
       snake_case__    :     ClassVar[Features]   		=			Features({'audio': Audio()}  )
       snake_case__    :     ClassVar[Features]   		=			Features({'transcription': Value('string'  )}  )
       snake_case__    :     str   		=			"audio"
       snake_case__    :     str   		=			"transcription"




       def 					a_					(					self      : Any	,    A__      : Any					):


            """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]	,    A__					):
                 raise ValueError(f"Column {self.audio_column} is not an Audio type."					)
            __lowerCamelCase						:       Dict				   =				copy.deepcopy(self					)
            __lowerCamelCase						:       List[Any]				   =				self.input_schema.copy()
            __lowerCamelCase						:       Optional[int]				   =				features[self.audio_column]
            __lowerCamelCase						:       Any				   =				input_schema
            return task_template




       @property
       def 					a_					(					self      : Any					):


            """simple docstring"""







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



