


'''simple docstring'''



from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional, Union

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


if TYPE_CHECKING:
      from ... import FeatureExtractionMixin, PreTrainedTokenizerBase, TensorType


A__		: List[Any]												=  logging.get_logger(__name__)

A__		: List[Any]												=  {
    """microsoft/deberta-base""": """https://huggingface.co/microsoft/deberta-base/resolve/main/config.json""",
    """microsoft/deberta-large""": """https://huggingface.co/microsoft/deberta-large/resolve/main/config.json""",
    """microsoft/deberta-xlarge""": """https://huggingface.co/microsoft/deberta-xlarge/resolve/main/config.json""",
    """microsoft/deberta-base-mnli""": """https://huggingface.co/microsoft/deberta-base-mnli/resolve/main/config.json""",
    """microsoft/deberta-large-mnli""": """https://huggingface.co/microsoft/deberta-large-mnli/resolve/main/config.json""",
    """microsoft/deberta-xlarge-mnli""": """https://huggingface.co/microsoft/deberta-xlarge-mnli/resolve/main/config.json""",
}





class        UpperCAmelCase_  (_UpperCAmelCase  ):





    """simple docstring"""






    lowerCamelCase  : int												=      'deberta'







    def __init__(							self      ,					SCREAMING_SNAKE_CASE_=5_02_65      ,					SCREAMING_SNAKE_CASE_=7_68      ,					SCREAMING_SNAKE_CASE_=12      ,					SCREAMING_SNAKE_CASE_=12      ,					SCREAMING_SNAKE_CASE_=30_72      ,					SCREAMING_SNAKE_CASE_="gelu"      ,					SCREAMING_SNAKE_CASE_=0.1      ,					SCREAMING_SNAKE_CASE_=0.1      ,					SCREAMING_SNAKE_CASE_=5_12      ,					SCREAMING_SNAKE_CASE_=0      ,					SCREAMING_SNAKE_CASE_=0.0_2      ,					SCREAMING_SNAKE_CASE_=1E-7      ,					SCREAMING_SNAKE_CASE_=False      ,					SCREAMING_SNAKE_CASE_=-1      ,					SCREAMING_SNAKE_CASE_=0      ,					SCREAMING_SNAKE_CASE_=True      ,					SCREAMING_SNAKE_CASE_=None      ,					SCREAMING_SNAKE_CASE_=0      ,					SCREAMING_SNAKE_CASE_="gelu"      ,					**SCREAMING_SNAKE_CASE_      ,					)    ->					Any:
         super().__init__(**SCREAMING_SNAKE_CASE_     )

         __lowerCamelCase       :     Any        =		hidden_size
         __lowerCamelCase       :     Dict        =		num_hidden_layers
         __lowerCamelCase       :     Union[str, Any]        =		num_attention_heads
         __lowerCamelCase       :     Optional[int]        =		intermediate_size
         __lowerCamelCase       :     Optional[Any]        =		hidden_act
         __lowerCamelCase       :     str        =		hidden_dropout_prob
         __lowerCamelCase       :     Tuple        =		attention_probs_dropout_prob
         __lowerCamelCase       :     str        =		max_position_embeddings
         __lowerCamelCase       :     List[str]        =		type_vocab_size
         __lowerCamelCase       :     int        =		initializer_range
         __lowerCamelCase       :     Optional[int]        =		relative_attention
         __lowerCamelCase       :     Any        =		max_relative_positions
         __lowerCamelCase       :     Tuple        =		pad_token_id
         __lowerCamelCase       :     Union[str, Any]        =		position_biased_input

         # Backwards compatibility
         if type(SCREAMING_SNAKE_CASE_     ) == str:
              __lowerCamelCase       :     Optional[int]        =		[x.strip() for x in pos_att_type.lower().split('|'     )]

         __lowerCamelCase       :     List[str]        =		pos_att_type
         __lowerCamelCase       :     Optional[int]        =		vocab_size
         __lowerCamelCase       :     Dict        =		layer_norm_eps

         __lowerCamelCase       :     Dict        =		kwargs.get('pooler_hidden_size'      ,					SCREAMING_SNAKE_CASE_     )
         __lowerCamelCase       :     List[Any]        =		pooler_dropout
         __lowerCamelCase       :     Union[str, Any]        =		pooler_hidden_act







class        UpperCAmelCase_  (_UpperCAmelCase  ):





    """simple docstring"""






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







    @property
    def 				lowercase_    (							self     )    ->					int:
         return 12







    def 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_ = -1      ,					SCREAMING_SNAKE_CASE_ = -1      ,					SCREAMING_SNAKE_CASE_ = -1      ,					SCREAMING_SNAKE_CASE_ = False      ,					SCREAMING_SNAKE_CASE_ = None      ,					SCREAMING_SNAKE_CASE_ = 3      ,					SCREAMING_SNAKE_CASE_ = 40      ,					SCREAMING_SNAKE_CASE_ = 40      ,					SCREAMING_SNAKE_CASE_ = None      ,					)    ->					Mapping[str, Any]:
         __lowerCamelCase       :     Tuple        =		super().generate_dummy_inputs(preprocessor=SCREAMING_SNAKE_CASE_      ,					framework=SCREAMING_SNAKE_CASE_     )
         if self._config.type_vocab_size == 0 and "token_type_ids" in dummy_inputs:
              del dummy_inputs["token_type_ids"]
         return dummy_inputs










'''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__		: Optional[int]												=  logging.get_logger(__name__)

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

A__		: Optional[int]												=  {
    """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__		: Any												=  {
    """openai/clip-vit-base-patch32""": 77,
}





class        UpperCAmelCase_  (_UpperCAmelCase  ):





    """simple docstring"""






    lowerCamelCase  : Union[str, Any]												=      VOCAB_FILES_NAMES
    lowerCamelCase  : Optional[int]												=      PRETRAINED_VOCAB_FILES_MAP
    lowerCamelCase  : str												=      PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    lowerCamelCase  : Union[str, Any]												=      ['input_ids', 'attention_mask']
    lowerCamelCase  : Optional[Any]												=      CLIPTokenizer







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

         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 				lowercase_    (							self     )    ->					Optional[Any]:
         __lowerCamelCase       :     Union[str, Any]        =		self.backend_tokenizer.decode

         def new_decode_method(*SCREAMING_SNAKE_CASE_      ,					**SCREAMING_SNAKE_CASE_     ):
              __lowerCamelCase       :     int        =		orig_decode_method(*SCREAMING_SNAKE_CASE_      ,					**SCREAMING_SNAKE_CASE_     )
              __lowerCamelCase       :     List[str]        =		text.replace(self.backend_tokenizer.model.end_of_word_suffix      ,					' '     ).strip()
              return text

         __lowerCamelCase       :     Union[str, Any]        =		new_decode_method







    def 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_ = None     )    ->					List[int]:
         __lowerCamelCase       :     Optional[int]        =		[self.bos_token_id]
         __lowerCamelCase       :     Tuple        =		[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 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_ = None     )    ->					List[int]:
         __lowerCamelCase       :     Dict        =		[self.bos_token_id]
         __lowerCamelCase       :     Optional[Any]        =		[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 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_ = None     )    ->					Tuple[str]:
         __lowerCamelCase       :     int        =		self._tokenizer.model.save(SCREAMING_SNAKE_CASE_      ,					name=SCREAMING_SNAKE_CASE_     )
         return tuple(SCREAMING_SNAKE_CASE_     )






