

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


_a				: Dict 							=						logging.get_logger(__name__)

_a				: Tuple 							=						{'vocab_file': 'vocab.json', 'merges_file': 'merges.txt', 'tokenizer_file': 'tokenizer.json'}

_a				: str 							=						{
    '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'
        ),
    },
}

_a				: Optional[int] 							=						{
    'openai/clip-vit-base-patch32': 77,
}



class        lowercase_	(		lowercase_ ):

  '''simple docstring'''





  __lowerCAmelCase					: str      =   VOCAB_FILES_NAMES
  __lowerCAmelCase					: List[Any]      =   PRETRAINED_VOCAB_FILES_MAP
  __lowerCAmelCase					: Optional[int]      =   PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
  __lowerCAmelCase					: Dict      =   ["""input_ids""", """attention_mask"""]
  __lowerCAmelCase					: int      =   CLIPTokenizer
  def __init__(     self   , a_=None   , a_=None   , a_=None   , a_="<|endoftext|>"   , a_="<|startoftext|>"   , a_="<|endoftext|>"   , a_="<|endoftext|>"   , **a_   , )							->				List[str]:


    """simple docstring"""
    super().__init__(
        a_   , a_   , tokenizer_file=a_   , unk_token=a_   , bos_token=a_   , eos_token=a_   , pad_token=a_   , **a_   , )

    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 						snake_case_			(     self     )							->				Dict:


    """simple docstring"""
    UpperCAmelCase													=	self.backend_tokenizer.decode

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

    UpperCAmelCase													=	new_decode_method
  def 						snake_case_			(     self   , a_   , a_ = None     )							->				Dict:


    """simple docstring"""
    UpperCAmelCase													=	[self.bos_token_id]
    UpperCAmelCase													=	[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 						snake_case_			(     self   , a_   , a_ = None     )							->				Optional[int]:


    """simple docstring"""
    UpperCAmelCase													=	[self.bos_token_id]
    UpperCAmelCase													=	[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 						snake_case_			(     self   , a_   , a_ = None     )							->				Any:


    """simple docstring"""
    UpperCAmelCase													=	self._tokenizer.model.save(a_   , name=a_     )
    return tuple(a_     )






'''simple docstring'''




from collections import OrderedDict
from typing import Mapping

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


_a				: Optional[int] 							=						logging.get_logger(__name__)

_a				: Dict 							=						{
    'mnaylor/mega-base-wikitext': 'https://huggingface.co/mnaylor/mega-base-wikitext/resolve/main/config.json',
}



class        lowercase_	(		a ):

  '''simple docstring'''





  __lowerCAmelCase					: List[str]      =   "mega"
  def __init__(     self   , a_=3_0_5_2_2   , a_=1_2_8   , a_=4   , a_=2_5_6   , a_=1_6   , a_=True   , a_=6_4   , a_=False   , a_=-1   , a_=None   , a_=True   , a_="scalenorm"   , a_=True   , a_="silu"   , a_="softmax"   , a_=0.1   , a_=0.1   , a_=0.1   , a_=False   , a_=True   , a_=2_5_6   , a_=True   , a_=0.1   , a_=2_0_4_8   , a_=False   , a_=2   , a_=0.02   , a_=0.2   , a_=0.02   , a_=1.0   , a_=1   , a_=0   , a_=2   , a_="rotary"   , a_=None   , a_=True   , a_=True   , **a_   , )							->				Any:


    """simple docstring"""
    super().__init__(pad_token_id=a_   , bos_token_id=a_   , eos_token_id=a_   , **a_     )

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




class        lowercase_	(		a ):

  '''simple docstring'''





  @property
  def 						snake_case_			(     self     )							->				Mapping[str, Mapping[int, str]]:


    """simple docstring"""
    if self.task == "multiple-choice":
      UpperCAmelCase													=	{0: 'batch', 1: 'choice', 2: 'sequence'}
    else:
      UpperCAmelCase													=	{0: 'batch', 1: 'sequence'}
    return OrderedDict(
        [
            ('input_ids', dynamic_axis),
            ('attention_mask', dynamic_axis),
        ]     )


