

'''simple docstring'''

from typing import List, Optional, Tuple

from tokenizers import pre_tokenizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_clip import CLIPTokenizer


lowerCAmelCase_						   =			logging.get_logger(__name__)

lowerCAmelCase_						   =			{"vocab_file": "vocab.json", "merges_file": "merges.txt", "tokenizer_file": "tokenizer.json"}

lowerCAmelCase_						   =			{
    "vocab_file": {
        "openai/clip-vit-base-patch32": "https://huggingface.co/openai/clip-vit-base-patch32/resolve/main/vocab.json",
    },
    "merges_file": {
        "openai/clip-vit-base-patch32": "https://huggingface.co/openai/clip-vit-base-patch32/resolve/main/merges.txt",
    },
    "tokenizer_file": {
        "openai/clip-vit-base-patch32": (
            "https://huggingface.co/openai/clip-vit-base-patch32/resolve/main/tokenizer.json"
        ),
    },
}

lowerCAmelCase_						   =			{
    "openai/clip-vit-base-patch32": 7_7,
}







class lowerCamelCase      (						__lowerCAmelCase							):
				snake_case_           =   VOCAB_FILES_NAMES
				snake_case_           =   PRETRAINED_VOCAB_FILES_MAP
				snake_case_           =   PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
				snake_case_           =   ['''input_ids''', '''attention_mask''']
				snake_case_           =   CLIPTokenizer

				def __init__(					self,	lowercase_=None,	lowercase_=None,	lowercase_=None,	lowercase_="<|endoftext|>",	lowercase_="<|startoftext|>",	lowercase_="<|endoftext|>",	lowercase_="<|endoftext|>",	**lowercase_,	)						->       Union[str, Any]:
					super().__init__(
					    lowercase_,	lowercase_,	tokenizer_file=lowercase_,	unk_token=lowercase_,	bos_token=lowercase_,	eos_token=lowercase_,	pad_token=lowercase_,	**lowercase_,	)

					if not isinstance(self.backend_tokenizer.pre_tokenizer,	pre_tokenizers.Sequence   ):
						raise ValueError(
						    'The `backend_tokenizer` provided does not match the expected format. The CLIP tokenizer has been'
						    ' heavily modified from transformers version 4.17.0. You need to convert the tokenizer you are using'
						    ' to be compatible with this version.The easiest way to do so is'
						    ' `CLIPTokenizerFast.from_pretrained("path_to_local_folder_or_hub_repo, from_slow=True)`. If you want'
						    ' to use your existing tokenizer, you will have to revert to a version prior to 4.17.0 of'
						    ' transformers.'   )

					self._wrap_decode_method_backend_tokenizer()

				def 				_lowerCamelCase						(					self   )						->       Dict:
					snake_case							 =				self.backend_tokenizer.decode

					def new_decode_method(*lowercase_,	**lowercase_   ):
						snake_case							 =				orig_decode_method(*lowercase_,	**lowercase_   )
						snake_case							 =				text.replace(self.backend_tokenizer.model.end_of_word_suffix,	' '   ).strip()
						return text

					snake_case							 =				new_decode_method

				def 				_lowerCamelCase						(					self,	lowercase_,	lowercase_ = None   )						->       List[int]:
					snake_case							 =				[self.bos_token_id]
					snake_case							 =				[self.eos_token_id]

					if token_ids_a is None:
						return bos_token + token_ids_a + eos_token
					return bos_token + token_ids_a + eos_token + eos_token + token_ids_a + eos_token

				def 				_lowerCamelCase						(					self,	lowercase_,	lowercase_ = None   )						->       List[int]:
					snake_case							 =				[self.bos_token_id]
					snake_case							 =				[self.eos_token_id]

					if token_ids_a is None:
						return len(bos_token + token_ids_a + eos_token   ) * [0]
					return len(bos_token + token_ids_a + eos_token + eos_token + token_ids_a + eos_token   ) * [0]






				def 				_lowerCamelCase						(					self,	lowercase_,	lowercase_ = None   )						->       Tuple[str]:
					snake_case							 =				self._tokenizer.model.save(lowercase_,	name=lowercase_   )
					return tuple(lowercase_   )








'''simple docstring'''

from collections import OrderedDict
from typing import Mapping

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


lowerCAmelCase_						   =			logging.get_logger(__name__)

lowerCAmelCase_						   =			{
    "mnaylor/mega-base-wikitext": "https://huggingface.co/mnaylor/mega-base-wikitext/resolve/main/config.json",
}







class lowerCamelCase      (						__lowerCAmelCase							):
				snake_case_           =   '''mega'''

				def __init__(					self,	lowercase_=30522,	lowercase_=128,	lowercase_=4,	lowercase_=256,	lowercase_=16,	lowercase_=True,	lowercase_=64,	lowercase_=False,	lowercase_=-1,	lowercase_=None,	lowercase_=True,	lowercase_="scalenorm",	lowercase_=True,	lowercase_="silu",	lowercase_="softmax",	lowercase_=0.1,	lowercase_=0.1,	lowercase_=0.1,	lowercase_=False,	lowercase_=True,	lowercase_=256,	lowercase_=True,	lowercase_=0.1,	lowercase_=2048,	lowercase_=False,	lowercase_=2,	lowercase_=0.02,	lowercase_=0.2,	lowercase_=0.02,	lowercase_=1.0,	lowercase_=1,	lowercase_=0,	lowercase_=2,	lowercase_="rotary",	lowercase_=None,	lowercase_=True,	lowercase_=True,	**lowercase_,	)						->       List[Any]:
					super().__init__(pad_token_id=lowercase_,	bos_token_id=lowercase_,	eos_token_id=lowercase_,	**lowercase_   )

					snake_case							 =				vocab_size
					snake_case							 =				hidden_size
					snake_case							 =				num_hidden_layers
					snake_case							 =				activation
					snake_case							 =				attention_activation
					snake_case							 =				intermediate_size
					snake_case							 =				ema_projection_size
					snake_case							 =				bidirectional
					snake_case							 =				shared_representation_size
					snake_case							 =				use_chunking
					snake_case							 =				chunk_size
					snake_case							 =				truncation
					snake_case							 =				normalize_before_mega
					snake_case							 =				normalization_type
					snake_case							 =				norm_affine
					snake_case							 =				dropout_prob
					snake_case							 =				hidden_dropout_prob
					snake_case							 =				attention_probs_dropout_prob
					snake_case							 =				use_feature_dropout
					snake_case							 =				use_normalized_ffn
					snake_case							 =				nffn_hidden_size
					snake_case							 =				normalize_before_ffn
					snake_case							 =				nffn_activation_dropout_prob
					snake_case							 =				max_positions
					snake_case							 =				add_token_type_embeddings
					snake_case							 =				type_vocab_size
					snake_case							 =				initializer_range
					snake_case							 =				ema_delta_alpha_range
					snake_case							 =				ema_beta_range
					snake_case							 =				ema_gamma_omega_range
					snake_case							 =				relative_positional_bias
					snake_case							 =				use_cache
					snake_case							 =				classifier_dropout
					snake_case							 =				add_lm_hidden_dense_layer
					snake_case							 =				1  # not used but required by Hugging Face







class lowerCamelCase      (						__lowerCAmelCase							):

				@property
				def 				_lowerCamelCase						(					self   )						->       Mapping[str, Mapping[int, str]]:
					if self.task == "multiple-choice":
						snake_case							 =				{0: 'batch', 1: 'choice', 2: 'sequence'}
					else:
						snake_case							 =				{0: 'batch', 1: 'sequence'}
					return OrderedDict(
					    [
					        ('input_ids', dynamic_axis),
					        ('attention_mask', dynamic_axis),
					    ]   )





