






'''simple docstring'''

import json
from typing import List, Optional, Tuple

from tokenizers import pre_tokenizers, processors

from ...tokenization_utils_base import AddedToken, BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_bart import BartTokenizer


UpperCAmelCase__						:Union[str, Any]          =			logging.get_logger(__name__)


UpperCAmelCase__						:List[Any]          =			{"""vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", """tokenizer_file""": """tokenizer.json"""}

# See all BART models at https://huggingface.co/models?filter=bart
UpperCAmelCase__						:Union[str, Any]          =			{
    """vocab_file""": {
        """facebook/bart-base""": """https://huggingface.co/facebook/bart-base/resolve/main/vocab.json""",
        """facebook/bart-large""": """https://huggingface.co/facebook/bart-large/resolve/main/vocab.json""",
        """facebook/bart-large-mnli""": """https://huggingface.co/facebook/bart-large-mnli/resolve/main/vocab.json""",
        """facebook/bart-large-cnn""": """https://huggingface.co/facebook/bart-large-cnn/resolve/main/vocab.json""",
        """facebook/bart-large-xsum""": """https://huggingface.co/facebook/bart-large-xsum/resolve/main/vocab.json""",
        """yjernite/bart_eli5""": """https://huggingface.co/yjernite/bart_eli5/resolve/main/vocab.json""",
    },
    """merges_file""": {
        """facebook/bart-base""": """https://huggingface.co/facebook/bart-base/resolve/main/merges.txt""",
        """facebook/bart-large""": """https://huggingface.co/facebook/bart-large/resolve/main/merges.txt""",
        """facebook/bart-large-mnli""": """https://huggingface.co/facebook/bart-large-mnli/resolve/main/merges.txt""",
        """facebook/bart-large-cnn""": """https://huggingface.co/facebook/bart-large-cnn/resolve/main/merges.txt""",
        """facebook/bart-large-xsum""": """https://huggingface.co/facebook/bart-large-xsum/resolve/main/merges.txt""",
        """yjernite/bart_eli5""": """https://huggingface.co/yjernite/bart_eli5/resolve/main/merges.txt""",
    },
    """tokenizer_file""": {
        """facebook/bart-base""": """https://huggingface.co/facebook/bart-base/resolve/main/tokenizer.json""",
        """facebook/bart-large""": """https://huggingface.co/facebook/bart-large/resolve/main/tokenizer.json""",
        """facebook/bart-large-mnli""": """https://huggingface.co/facebook/bart-large-mnli/resolve/main/tokenizer.json""",
        """facebook/bart-large-cnn""": """https://huggingface.co/facebook/bart-large-cnn/resolve/main/tokenizer.json""",
        """facebook/bart-large-xsum""": """https://huggingface.co/facebook/bart-large-xsum/resolve/main/tokenizer.json""",
        """yjernite/bart_eli5""": """https://huggingface.co/yjernite/bart_eli5/resolve/main/tokenizer.json""",
    },
}

UpperCAmelCase__						:List[Any]          =			{
    """facebook/bart-base""": 1_024,
    """facebook/bart-large""": 1_024,
    """facebook/bart-large-mnli""": 1_024,
    """facebook/bart-large-cnn""": 1_024,
    """facebook/bart-large-xsum""": 1_024,
    """yjernite/bart_eli5""": 1_024,
}







class 	SCREAMING_SNAKE_CASE	(      lowerCAmelCase_  ):
							snake_case__    :     Any   		=			VOCAB_FILES_NAMES
							snake_case__    :     Any   		=			PRETRAINED_VOCAB_FILES_MAP
							snake_case__    :     Any   		=			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							snake_case__    :     Optional[int]   		=			['input_ids', 'attention_mask']
							snake_case__    :     Any   		=			BartTokenizer




							def __init__(					self      : List[str]	,    A__      : Union[str, Any]=None	,    A__      : Any=None	,    A__      : str=None	,    A__      : List[str]="replace"	,    A__      : Dict="<s>"	,    A__      : List[str]="</s>"	,    A__      : Any="</s>"	,    A__      : int="<s>"	,    A__      : Any="<unk>"	,    A__      : Dict="<pad>"	,    A__      : Optional[Any]="<mask>"	,    A__      : str=False	,    A__      : Optional[int]=True	,    **A__      : Any	,    ):


												"""simple docstring"""







												super().__init__(
												    A__	,    A__	,    tokenizer_file=A__	,    errors=A__	,    bos_token=A__	,    eos_token=A__	,    sep_token=A__	,    cls_token=A__	,    unk_token=A__	,    pad_token=A__	,    mask_token=A__	,    add_prefix_space=A__	,    trim_offsets=A__	,    **A__	,    )

												__lowerCamelCase						:       Union[str, Any]				   =				json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()					)
												if pre_tok_state.get("""add_prefix_space"""	,    A__					) != add_prefix_space:
																	__lowerCamelCase						:       List[Any]				   =				getattr(A__	,    pre_tok_state.pop("""type"""					)					)
																	__lowerCamelCase						:       Union[str, Any]				   =				add_prefix_space
																	__lowerCamelCase						:       Any				   =				pre_tok_class(**A__					)

												__lowerCamelCase						:       str				   =				add_prefix_space

												# the pre_tokenizer is already updated in the GPT2TokenizerFast `__init__`
												__lowerCamelCase						:       List[Any]				   =				"""post_processor"""
												__lowerCamelCase						:       List[str]				   =				getattr(self.backend_tokenizer	,    A__	,    A__					)
												if tokenizer_component_instance:
																	__lowerCamelCase						:       Union[str, Any]				   =				json.loads(tokenizer_component_instance.__getstate__()					)

																	# The lists 'sep' and 'cls' must be cased in tuples for the object `post_processor_class`
																	if "sep" in state:
																						__lowerCamelCase						:       Union[str, Any]				   =				tuple(state["""sep"""]					)
																	if "cls" in state:
																						__lowerCamelCase						:       List[str]				   =				tuple(state["""cls"""]					)

																	__lowerCamelCase						:       Optional[int]				   =				False

																	if state.get("""add_prefix_space"""	,    A__					) != add_prefix_space:
																						__lowerCamelCase						:       Dict				   =				add_prefix_space
																						__lowerCamelCase						:       int				   =				True

																	if state.get("""trim_offsets"""	,    A__					) != trim_offsets:
																						__lowerCamelCase						:       Optional[Any]				   =				trim_offsets
																						__lowerCamelCase						:       List[str]				   =				True

																	if changes_to_apply:
																						__lowerCamelCase						:       Any				   =				getattr(A__	,    state.pop("""type"""					)					)
																						__lowerCamelCase						:       Union[str, Any]				   =				component_class(**A__					)
																						setattr(self.backend_tokenizer	,    A__	,    A__					)




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


												"""simple docstring"""







												if self._mask_token is None:
																	if self.verbose:
																						logger.error("""Using mask_token, but it is not set yet."""					)
																	return None
												return str(self._mask_token					)




							@mask_token.setter
							def 					a_					(					self      : List[Any]	,    A__      : str					):


												"""simple docstring"""







												__lowerCamelCase						:       Tuple				   =				AddedToken(A__	,    lstrip=A__	,    rstrip=A__					) if isinstance(A__	,    A__					) else value
												__lowerCamelCase						:       str				   =				value




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


												"""simple docstring"""







												__lowerCamelCase						:       Optional[Any]				   =				kwargs.get("""is_split_into_words"""	,    A__					)

												if is_split_into_words and not self.add_prefix_space:
																	raise ValueError(
																	    f"You need to instantiate {self.__class__.__name__} with add_prefix_space=True "
																	    """to use it with pretokenized inputs."""					)

												return super()._batch_encode_plus(*A__	,    **A__					)




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


												"""simple docstring"""







												__lowerCamelCase						:       List[Any]				   =				kwargs.get("""is_split_into_words"""	,    A__					)

												if is_split_into_words and not self.add_prefix_space:
																	raise ValueError(
																	    f"You need to instantiate {self.__class__.__name__} with add_prefix_space=True "
																	    """to use it with pretokenized inputs."""					)

												return super()._encode_plus(*A__	,    **A__					)




							def 					a_					(					self      : Optional[int]	,    A__      : str	,    A__      : Optional[str] = None					):


												"""simple docstring"""







												__lowerCamelCase						:       List[Any]				   =				self._tokenizer.model.save(A__	,    name=A__					)
												return tuple(A__					)




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


												"""simple docstring"""







												__lowerCamelCase						:       Union[str, Any]				   =				[self.bos_token_id] + token_ids_a + [self.eos_token_id]
												if token_ids_a is None:
																	return output

												return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]




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


												"""simple docstring"""







												__lowerCamelCase						:       Tuple				   =				[self.sep_token_id]
												__lowerCamelCase						:       str				   =				[self.cls_token_id]

												if token_ids_a is None:
																	return len(cls + token_ids_a + sep					) * [0]
												return len(cls + token_ids_a + sep + sep + token_ids_a + sep					) * [0]











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



