






import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_bert import BertTokenizer


UpperCAmelCase_ :						Optional[Any]      =      logging.get_logger(__name__)

UpperCAmelCase_ :						Optional[Any]      =      {'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

UpperCAmelCase_ :						Tuple      =      {
    '''vocab_file''': {
        '''bert-base-uncased''': '''https://huggingface.co/bert-base-uncased/resolve/main/vocab.txt''',
        '''bert-large-uncased''': '''https://huggingface.co/bert-large-uncased/resolve/main/vocab.txt''',
        '''bert-base-cased''': '''https://huggingface.co/bert-base-cased/resolve/main/vocab.txt''',
        '''bert-large-cased''': '''https://huggingface.co/bert-large-cased/resolve/main/vocab.txt''',
        '''bert-base-multilingual-uncased''': (
            '''https://huggingface.co/bert-base-multilingual-uncased/resolve/main/vocab.txt'''
        ),
        '''bert-base-multilingual-cased''': '''https://huggingface.co/bert-base-multilingual-cased/resolve/main/vocab.txt''',
        '''bert-base-chinese''': '''https://huggingface.co/bert-base-chinese/resolve/main/vocab.txt''',
        '''bert-base-german-cased''': '''https://huggingface.co/bert-base-german-cased/resolve/main/vocab.txt''',
        '''bert-large-uncased-whole-word-masking''': (
            '''https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/vocab.txt'''
        ),
        '''bert-large-cased-whole-word-masking''': (
            '''https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/vocab.txt'''
        ),
        '''bert-large-uncased-whole-word-masking-finetuned-squad''': (
            '''https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/vocab.txt'''
        ),
        '''bert-large-cased-whole-word-masking-finetuned-squad''': (
            '''https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/vocab.txt'''
        ),
        '''bert-base-cased-finetuned-mrpc''': (
            '''https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/vocab.txt'''
        ),
        '''bert-base-german-dbmdz-cased''': '''https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/vocab.txt''',
        '''bert-base-german-dbmdz-uncased''': (
            '''https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/vocab.txt'''
        ),
        '''TurkuNLP/bert-base-finnish-cased-v1''': (
            '''https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/vocab.txt'''
        ),
        '''TurkuNLP/bert-base-finnish-uncased-v1''': (
            '''https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/vocab.txt'''
        ),
        '''wietsedv/bert-base-dutch-cased''': (
            '''https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/vocab.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''bert-base-uncased''': '''https://huggingface.co/bert-base-uncased/resolve/main/tokenizer.json''',
        '''bert-large-uncased''': '''https://huggingface.co/bert-large-uncased/resolve/main/tokenizer.json''',
        '''bert-base-cased''': '''https://huggingface.co/bert-base-cased/resolve/main/tokenizer.json''',
        '''bert-large-cased''': '''https://huggingface.co/bert-large-cased/resolve/main/tokenizer.json''',
        '''bert-base-multilingual-uncased''': (
            '''https://huggingface.co/bert-base-multilingual-uncased/resolve/main/tokenizer.json'''
        ),
        '''bert-base-multilingual-cased''': (
            '''https://huggingface.co/bert-base-multilingual-cased/resolve/main/tokenizer.json'''
        ),
        '''bert-base-chinese''': '''https://huggingface.co/bert-base-chinese/resolve/main/tokenizer.json''',
        '''bert-base-german-cased''': '''https://huggingface.co/bert-base-german-cased/resolve/main/tokenizer.json''',
        '''bert-large-uncased-whole-word-masking''': (
            '''https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/tokenizer.json'''
        ),
        '''bert-large-cased-whole-word-masking''': (
            '''https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/tokenizer.json'''
        ),
        '''bert-large-uncased-whole-word-masking-finetuned-squad''': (
            '''https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/tokenizer.json'''
        ),
        '''bert-large-cased-whole-word-masking-finetuned-squad''': (
            '''https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/tokenizer.json'''
        ),
        '''bert-base-cased-finetuned-mrpc''': (
            '''https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/tokenizer.json'''
        ),
        '''bert-base-german-dbmdz-cased''': (
            '''https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/tokenizer.json'''
        ),
        '''bert-base-german-dbmdz-uncased''': (
            '''https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/tokenizer.json'''
        ),
        '''TurkuNLP/bert-base-finnish-cased-v1''': (
            '''https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/tokenizer.json'''
        ),
        '''TurkuNLP/bert-base-finnish-uncased-v1''': (
            '''https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/tokenizer.json'''
        ),
        '''wietsedv/bert-base-dutch-cased''': (
            '''https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/tokenizer.json'''
        ),
    },
}

UpperCAmelCase_ :						Optional[int]      =      {
    '''bert-base-uncased''': 5_12,
    '''bert-large-uncased''': 5_12,
    '''bert-base-cased''': 5_12,
    '''bert-large-cased''': 5_12,
    '''bert-base-multilingual-uncased''': 5_12,
    '''bert-base-multilingual-cased''': 5_12,
    '''bert-base-chinese''': 5_12,
    '''bert-base-german-cased''': 5_12,
    '''bert-large-uncased-whole-word-masking''': 5_12,
    '''bert-large-cased-whole-word-masking''': 5_12,
    '''bert-large-uncased-whole-word-masking-finetuned-squad''': 5_12,
    '''bert-large-cased-whole-word-masking-finetuned-squad''': 5_12,
    '''bert-base-cased-finetuned-mrpc''': 5_12,
    '''bert-base-german-dbmdz-cased''': 5_12,
    '''bert-base-german-dbmdz-uncased''': 5_12,
    '''TurkuNLP/bert-base-finnish-cased-v1''': 5_12,
    '''TurkuNLP/bert-base-finnish-uncased-v1''': 5_12,
    '''wietsedv/bert-base-dutch-cased''': 5_12,
}

UpperCAmelCase_ :						List[str]      =      {
    '''bert-base-uncased''': {'''do_lower_case''': True},
    '''bert-large-uncased''': {'''do_lower_case''': True},
    '''bert-base-cased''': {'''do_lower_case''': False},
    '''bert-large-cased''': {'''do_lower_case''': False},
    '''bert-base-multilingual-uncased''': {'''do_lower_case''': True},
    '''bert-base-multilingual-cased''': {'''do_lower_case''': False},
    '''bert-base-chinese''': {'''do_lower_case''': False},
    '''bert-base-german-cased''': {'''do_lower_case''': False},
    '''bert-large-uncased-whole-word-masking''': {'''do_lower_case''': True},
    '''bert-large-cased-whole-word-masking''': {'''do_lower_case''': False},
    '''bert-large-uncased-whole-word-masking-finetuned-squad''': {'''do_lower_case''': True},
    '''bert-large-cased-whole-word-masking-finetuned-squad''': {'''do_lower_case''': False},
    '''bert-base-cased-finetuned-mrpc''': {'''do_lower_case''': False},
    '''bert-base-german-dbmdz-cased''': {'''do_lower_case''': False},
    '''bert-base-german-dbmdz-uncased''': {'''do_lower_case''': True},
    '''TurkuNLP/bert-base-finnish-cased-v1''': {'''do_lower_case''': False},
    '''TurkuNLP/bert-base-finnish-uncased-v1''': {'''do_lower_case''': True},
    '''wietsedv/bert-base-dutch-cased''': {'''do_lower_case''': False},
}

class     _SCREAMING_SNAKE_CASE       (			_a      ):
	snake_case__							:     Tuple     	=  VOCAB_FILES_NAMES
	snake_case__							:     List[str]     	=  PRETRAINED_VOCAB_FILES_MAP
	snake_case__							:     Optional[Any]     	=  PRETRAINED_INIT_CONFIGURATION
	snake_case__							:     List[Any]     	=  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	snake_case__							:     List[str]     	=  BertTokenizer





	def __init__(		self				:					Optional[Any] ,  __lowerCamelCase				:					str=None ,  __lowerCamelCase				:					Tuple=None ,  __lowerCamelCase				:					Optional[Any]=True ,  __lowerCamelCase				:					Tuple="[UNK]" ,  __lowerCamelCase				:					Dict="[SEP]" ,  __lowerCamelCase				:					Any="[PAD]" ,  __lowerCamelCase				:					str="[CLS]" ,  __lowerCamelCase				:					Dict="[MASK]" ,  __lowerCamelCase				:					Optional[int]=True ,  __lowerCamelCase				:					Tuple=None ,  **__lowerCamelCase				:					Union[str, Any] ,  ):
		super().__init__(
		    __lowerCamelCase ,  tokenizer_file=__lowerCamelCase ,  do_lower_case=__lowerCamelCase ,  unk_token=__lowerCamelCase ,  sep_token=__lowerCamelCase ,  pad_token=__lowerCamelCase ,  cls_token=__lowerCamelCase ,  mask_token=__lowerCamelCase ,  tokenize_chinese_chars=__lowerCamelCase ,  strip_accents=__lowerCamelCase ,  **__lowerCamelCase ,  )

		UpperCamelCase     :Any          =	json.loads(self.backend_tokenizer.normalizer.__getstate__()	)
		if (
		    normalizer_state.get("""lowercase""" ,  __lowerCamelCase	) != do_lower_case
		    or normalizer_state.get("""strip_accents""" ,  __lowerCamelCase	) != strip_accents
		    or normalizer_state.get("""handle_chinese_chars""" ,  __lowerCamelCase	) != tokenize_chinese_chars
		):
			UpperCamelCase     :Union[str, Any]          =	getattr(__lowerCamelCase ,  normalizer_state.pop("""type"""	)	)
			UpperCamelCase     :Optional[int]          =	do_lower_case
			UpperCamelCase     :Tuple          =	strip_accents
			UpperCamelCase     :str          =	tokenize_chinese_chars
			UpperCamelCase     :str          =	normalizer_class(**__lowerCamelCase	)

		UpperCamelCase     :Optional[int]          =	do_lower_case





	def 						_A (		self				:					Any ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					Any=None	):
		UpperCamelCase     :Tuple          =	[self.cls_token_id] + token_ids_a + [self.sep_token_id]

		if token_ids_a:
			output += token_ids_a + [self.sep_token_id]

		return output





	def 						_A (		self				:					Union[str, Any] ,  __lowerCamelCase				:					List[int] ,  __lowerCamelCase				:					Optional[List[int]] = None	):
		UpperCamelCase     :Optional[int]          =	[self.sep_token_id]
		UpperCamelCase     :Optional[int]          =	[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	) * [0] + len(token_ids_a + sep	) * [1]





	def 						_A (		self				:					List[Any] ,  __lowerCamelCase				:					str ,  __lowerCamelCase				:					Optional[str] = None	):
		UpperCamelCase     :Dict          =	self._tokenizer.model.save(__lowerCamelCase ,  name=__lowerCamelCase	)
		return tuple(__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=_a      )
class     _SCREAMING_SNAKE_CASE       (			_a      ):
	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				:					List[str] ,  __lowerCamelCase				:					Dict	):
		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."""	)
		UpperCamelCase     :int          =	copy.deepcopy(self	)
		UpperCamelCase     :Any          =	self.input_schema.copy()
		UpperCamelCase     :List[str]          =	features[self.audio_column]
		UpperCamelCase     :List[Any]          =	input_schema
		return task_template





	@property
	def 						_A (		self				:					Optional[int]	):
		return {self.audio_column: "audio", self.transcription_column: "transcription"}
