
from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


UpperCAmelCase__					:	str							       =					logging.get_logger(__name__)

UpperCAmelCase__					:	Any							       =					{
    '''facebook/data2vec-vision-base-ft''': (
        '''https://huggingface.co/facebook/data2vec-vision-base-ft/resolve/main/config.json'''
    ),
}



class       UpperCamelCase_      (    snake_case_ ):




							'''simple docstring'''

							UpperCamelCase_        =				"""data2vec-vision"""
							def __init__(					self  ,    UpperCamelCase=7_68  ,    UpperCamelCase=12  ,    UpperCamelCase=12  ,    UpperCamelCase=30_72  ,    UpperCamelCase="gelu"  ,    UpperCamelCase=0.0  ,    UpperCamelCase=0.0  ,    UpperCamelCase=0.02  ,    UpperCamelCase=1E-12  ,    UpperCamelCase=2_24  ,    UpperCamelCase=16  ,    UpperCamelCase=3  ,    UpperCamelCase=False  ,    UpperCamelCase=False  ,    UpperCamelCase=False  ,    UpperCamelCase=False  ,    UpperCamelCase=0.1  ,    UpperCamelCase=0.1  ,    UpperCamelCase=True  ,    UpperCamelCase=[3, 5, 7, 11]  ,    UpperCamelCase=[1, 2, 3, 6]  ,    UpperCamelCase=True  ,    UpperCamelCase=0.4  ,    UpperCamelCase=2_56  ,    UpperCamelCase=1  ,    UpperCamelCase=False  ,    UpperCamelCase=2_55  ,    **UpperCamelCase  ,    )			->						Optional[int]:
										super().__init__(**UpperCamelCase)

										UpperCamelCase__     :		int	 =					hidden_size
										UpperCamelCase__     :		Tuple	 =					num_hidden_layers
										UpperCamelCase__     :		str	 =					num_attention_heads
										UpperCamelCase__     :		Optional[int]	 =					intermediate_size
										UpperCamelCase__     :		Optional[int]	 =					hidden_act
										UpperCamelCase__     :		int	 =					hidden_dropout_prob
										UpperCamelCase__     :		Optional[int]	 =					attention_probs_dropout_prob
										UpperCamelCase__     :		int	 =					initializer_range
										UpperCamelCase__     :		Dict	 =					layer_norm_eps

										UpperCamelCase__     :		int	 =					image_size
										UpperCamelCase__     :		Dict	 =					patch_size
										UpperCamelCase__     :		Any	 =					num_channels
										UpperCamelCase__     :		Dict	 =					use_mask_token
										UpperCamelCase__     :		Dict	 =					use_absolute_position_embeddings
										UpperCamelCase__     :		Any	 =					use_relative_position_bias
										UpperCamelCase__     :		List[str]	 =					use_shared_relative_position_bias
										UpperCamelCase__     :		int	 =					layer_scale_init_value
										UpperCamelCase__     :		List[str]	 =					drop_path_rate
										UpperCamelCase__     :		Dict	 =					use_mean_pooling
										# decode head attributes (semantic segmentation)
										UpperCamelCase__     :		Optional[int]	 =					out_indices
										UpperCamelCase__     :		Dict	 =					pool_scales
										# auxiliary head attributes (semantic segmentation)
										UpperCamelCase__     :		str	 =					use_auxiliary_head
										UpperCamelCase__     :		Optional[int]	 =					auxiliary_loss_weight
										UpperCamelCase__     :		Optional[Any]	 =					auxiliary_channels
										UpperCamelCase__     :		Optional[int]	 =					auxiliary_num_convs
										UpperCamelCase__     :		Tuple	 =					auxiliary_concat_input
										UpperCamelCase__     :		List[str]	 =					semantic_loss_ignore_index



class       UpperCamelCase_      (    snake_case_ ):




							'''simple docstring'''

							UpperCamelCase_        =				version.parse("""1.11""" )
							@property
							def 							lowerCAmelCase__			(					self)			->						Mapping[str, Mapping[int, str]]:
										return OrderedDict(
										    [
										        ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
										    ])






							@property
							def 							lowerCAmelCase__			(					self)			->						float:
										return 1E-4





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_funnel import FunnelTokenizer


__A							=logging.get_logger(__name__)

__A							={'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

__A							=[
    '''small''',
    '''small-base''',
    '''medium''',
    '''medium-base''',
    '''intermediate''',
    '''intermediate-base''',
    '''large''',
    '''large-base''',
    '''xlarge''',
    '''xlarge-base''',
]

__A							={
    '''vocab_file''': {
        '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/vocab.txt''',
        '''funnel-transformer/small-base''': '''https://huggingface.co/funnel-transformer/small-base/resolve/main/vocab.txt''',
        '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/vocab.txt''',
        '''funnel-transformer/medium-base''': (
            '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/intermediate''': (
            '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/intermediate-base''': (
            '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/vocab.txt''',
        '''funnel-transformer/large-base''': '''https://huggingface.co/funnel-transformer/large-base/resolve/main/vocab.txt''',
        '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/vocab.txt''',
        '''funnel-transformer/xlarge-base''': (
            '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/vocab.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/tokenizer.json''',
        '''funnel-transformer/small-base''': (
            '''https://huggingface.co/funnel-transformer/small-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/tokenizer.json''',
        '''funnel-transformer/medium-base''': (
            '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/intermediate''': (
            '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/intermediate-base''': (
            '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/tokenizer.json''',
        '''funnel-transformer/large-base''': (
            '''https://huggingface.co/funnel-transformer/large-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/tokenizer.json''',
        '''funnel-transformer/xlarge-base''': (
            '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/tokenizer.json'''
        ),
    },
}
__A							={F"""funnel-transformer/{name}""": 5_1_2 for name in _model_names}
__A							={F"""funnel-transformer/{name}""": {'''do_lower_case''': True} for name in _model_names}




class        _SCREAMING_SNAKE_CASE	( snake_case_		):
	lowerCAmelCase__   =					VOCAB_FILES_NAMES
	lowerCAmelCase__   =					PRETRAINED_VOCAB_FILES_MAP
	lowerCAmelCase__   =					PRETRAINED_INIT_CONFIGURATION
	lowerCAmelCase__   =					FunnelTokenizer
	lowerCAmelCase__   =					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	lowerCAmelCase__   =					2



	def __init__(       self		,    lowercase=None		,    lowercase=None		,    lowercase=True		,    lowercase="<unk>"		,    lowercase="<sep>"		,    lowercase="<pad>"		,    lowercase="<cls>"		,    lowercase="<mask>"		,    lowercase="<s>"		,    lowercase="</s>"		,    lowercase=True		,    lowercase=True		,    lowercase=None		,    lowercase="##"		,    **lowercase		,    )							->			List[str]:
					super().__init__(
					    lowercase		,    tokenizer_file=lowercase		,    do_lower_case=lowercase		,    unk_token=lowercase		,    sep_token=lowercase		,    pad_token=lowercase		,    cls_token=lowercase		,    mask_token=lowercase		,    bos_token=lowercase		,    eos_token=lowercase		,    clean_text=lowercase		,    tokenize_chinese_chars=lowercase		,    strip_accents=lowercase		,    wordpieces_prefix=lowercase		,    **lowercase		,    )

					lowerCamelCase_         =     json.loads(self.backend_tokenizer.normalizer.__getstate__()					)
					if (
					    normalizer_state.get("lowercase"		,    lowercase					) != do_lower_case
					    or normalizer_state.get("strip_accents"		,    lowercase					) != strip_accents
					    or normalizer_state.get("handle_chinese_chars"		,    lowercase					) != tokenize_chinese_chars
					):
									lowerCamelCase_         =     getattr(lowercase		,    normalizer_state.pop("type"					)					)
									lowerCamelCase_         =     do_lower_case
									lowerCamelCase_         =     strip_accents
									lowerCamelCase_         =     tokenize_chinese_chars
									lowerCamelCase_         =     normalizer_class(**lowercase					)

					lowerCamelCase_         =     do_lower_case



	def        SCREAMING_SNAKE_CASE_(       self		,    lowercase		,    lowercase=None					)							->			str:
					lowerCamelCase_         =     [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        SCREAMING_SNAKE_CASE_(       self		,    lowercase		,    lowercase = None					)							->			List[int]:
					lowerCamelCase_         =     [self.sep_token_id]
					lowerCamelCase_         =     [self.cls_token_id]
					if token_ids_a is None:
									return len(cls					) * [self.cls_token_type_id] + len(token_ids_a + sep					) * [0]
					return len(cls					) * [self.cls_token_type_id] + len(token_ids_a + sep					) * [0] + len(token_ids_a + sep					) * [1]



	def        SCREAMING_SNAKE_CASE_(       self		,    lowercase		,    lowercase = None					)							->			Tuple[str]:
					lowerCamelCase_         =     self._tokenizer.model.save(lowercase		,    name=lowercase					)
					return tuple(lowercase					)


