





"""simple docstring"""


import json
import os
import unittest

from transformers import DebertaTokenizer, DebertaTokenizerFast
from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES
from transformers.testing_utils import slow

from ...test_tokenization_common import TokenizerTesterMixin



class      __SCREAMING_SNAKE_CASE    (						_UpperCamelCase		,  unittest.TestCase   ):







		'''simple docstring'''


		SCREAMING_SNAKE_CASE__							:int	     =					DebertaTokenizer
		SCREAMING_SNAKE_CASE__							:Any	     =					True
		SCREAMING_SNAKE_CASE__							:Any	     =					DebertaTokenizerFast

		def    __SCREAMING_SNAKE_CASE				(		self   :       Dict	)		->				Dict:
								super().setUp()

								# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
								_UpperCamelCase      :	List[str]						=       [
								    "l",
								    "o",
								    "w",
								    "e",
								    "r",
								    "s",
								    "t",
								    "i",
								    "d",
								    "n",
								    "\u0120",
								    "\u0120l",
								    "\u0120n",
								    "\u0120lo",
								    "\u0120low",
								    "er",
								    "\u0120lowest",
								    "\u0120newer",
								    "\u0120wider",
								    "[UNK]",
								]
								_UpperCamelCase      :	List[Any]						=       dict(zip(__lowerCAmelCase					,   range(len(__lowerCAmelCase	)	)	)	)
								_UpperCamelCase      :	List[str]						=       ["#version: 0.2", "\u0120 l", "\u0120l o", "\u0120lo w", "e r", ""]
								_UpperCamelCase      :	Optional[int]						=       {"unk_token": "[UNK]"}

								_UpperCamelCase      :	Optional[int]						=       os.path.join(self.tmpdirname					,   VOCAB_FILES_NAMES["vocab_file"]	)
								_UpperCamelCase      :	Optional[int]						=       os.path.join(self.tmpdirname					,   VOCAB_FILES_NAMES["merges_file"]	)
								with open(self.vocab_file					,   "w"					,   encoding="utf-8"	) as fp:
														fp.write(json.dumps(__lowerCAmelCase	) + "\n"	)
								with open(self.merges_file					,   "w"					,   encoding="utf-8"	) as fp:
														fp.write("\n".join(__lowerCAmelCase	)	)

		def    __SCREAMING_SNAKE_CASE				(		self   :       Optional[int]					,   **__a   :       Any	)		->				str:
								kwargs.update(self.special_tokens_map	)
								return self.tokenizer_class.from_pretrained(self.tmpdirname					,   **__lowerCAmelCase	)

		def    __SCREAMING_SNAKE_CASE				(		self   :       int					,   __a   :       List[str]	)		->				Tuple:
								_UpperCamelCase      :	Optional[int]						=       "lower newer"
								_UpperCamelCase      :	Optional[Any]						=       "lower newer"
								return input_text, output_text

		def    __SCREAMING_SNAKE_CASE				(		self   :       Tuple	)		->				Dict:
								_UpperCamelCase      :	Dict						=       self.get_tokenizer()
								_UpperCamelCase      :	Optional[Any]						=       "lower newer"
								_UpperCamelCase      :	List[str]						=       ["l", "o", "w", "er", "\u0120", "n", "e", "w", "er"]
								_UpperCamelCase      :	Optional[Any]						=       tokenizer.tokenize(__lowerCAmelCase	)
								self.assertListEqual(__lowerCAmelCase					,   __lowerCAmelCase	)

								_UpperCamelCase      :	Tuple						=       tokens + [tokenizer.unk_token]
								_UpperCamelCase      :	Optional[Any]						=       [0, 1, 2, 15, 10, 9, 3, 2, 15, 19]
								self.assertListEqual(tokenizer.convert_tokens_to_ids(__lowerCAmelCase	)					,   __lowerCAmelCase	)

		def    __SCREAMING_SNAKE_CASE				(		self   :       Optional[int]	)		->				Optional[Any]:
								_UpperCamelCase      :	str						=       self.get_tokenizer()
								_UpperCamelCase      :	Tuple						=       tokenizer("Hello"					,   "World"	)
								_UpperCamelCase      :	Optional[Any]						=       [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]
								self.assertListEqual(tokd["token_type_ids"]					,   __lowerCAmelCase	)

		@slow
		def    __SCREAMING_SNAKE_CASE				(		self   :       Optional[int]	)		->				str:
								_UpperCamelCase      :	Optional[Any]						=       self.tokenizer_class.from_pretrained("microsoft/deberta-base"	)

								_UpperCamelCase      :	Union[str, Any]						=       tokenizer.encode("sequence builders"					,   add_special_tokens=__lowerCAmelCase	)
								_UpperCamelCase      :	List[Any]						=       tokenizer.encode("multi-sequence build"					,   add_special_tokens=__lowerCAmelCase	)

								_UpperCamelCase      :	Optional[int]						=       tokenizer.encode(
								    "sequence builders"					,   add_special_tokens=__lowerCAmelCase					,   add_prefix_space=__lowerCAmelCase	)
								_UpperCamelCase      :	List[str]						=       tokenizer.encode(
								    "sequence builders"					,   "multi-sequence build"					,   add_special_tokens=__lowerCAmelCase					,   add_prefix_space=__lowerCAmelCase	)

								_UpperCamelCase      :	List[Any]						=       tokenizer.build_inputs_with_special_tokens(__lowerCAmelCase	)
								_UpperCamelCase      :	Dict						=       tokenizer.build_inputs_with_special_tokens(__lowerCAmelCase					,   __lowerCAmelCase	)

								assert encoded_sentence == encoded_text_from_decode
								assert encoded_pair == encoded_pair_from_decode


		@slow
		def    __SCREAMING_SNAKE_CASE				(		self   :       Optional[int]	)		->				List[Any]:
								_UpperCamelCase      :	Union[str, Any]						=       [self.tokenizer_class]
								if self.test_rust_tokenizer:
														tokenizer_classes.append(self.rust_tokenizer_class	)

								for tokenizer_class in tokenizer_classes:
														_UpperCamelCase      :	List[Any]						=       tokenizer_class.from_pretrained("microsoft/deberta-base"	)

														_UpperCamelCase      :	List[Any]						=       [
														    "ALBERT: A Lite BERT for Self-supervised Learning of Language Representations",
														    "ALBERT incorporates two parameter reduction techniques",
														    "The first one is a factorized embedding parameterization. By decomposing the large vocabulary"
														    " embedding matrix into two small matrices, we separate the size of the hidden layers from the size of"
														    " vocabulary embedding.",
														]

														_UpperCamelCase      :	str						=       tokenizer(__lowerCAmelCase					,   padding=__lowerCAmelCase	)
														_UpperCamelCase      :	Dict						=       [tokenizer.decode(__lowerCAmelCase					,   skip_special_tokens=__lowerCAmelCase	) for seq in encoding["input_ids"]]

														# fmt: off
														_UpperCamelCase      :	Optional[int]						=       {
														    "input_ids": [
														        [1, 2118, 1_1126, 565, 35, 83, 2_5191, 163, 1_8854, 13, 1_2156, 12, 1_6101, 2_5376, 1_3807, 9, 2_2205, 2_7893, 1635, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
														        [1, 2118, 1_1126, 565, 2_4536, 80, 4_3797, 4878, 7373, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
														        [1, 133, 78, 65, 16, 10, 3724, 1538, 3_3183, 1_1303, 4_3797, 1938, 4, 870, 2_4165, 2_9105, 5, 739, 3_2644, 3_3183, 1_1303, 3_6173, 88, 80, 650, 7821, 4_5940, 6, 52, 2559, 5, 1836, 9, 5, 7397, 1_3171, 31, 5, 1836, 9, 3_2644, 3_3183, 1_1303, 4, 2]
														    ],
														    "token_type_ids": [
														        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
														        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
														        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
														    ],
														    "attention_mask": [
														        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
														        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
														        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
														    ]
														}
														# fmt: on

														_UpperCamelCase      :	Any						=       [
														    "ALBERT: A Lite BERT for Self-supervised Learning of Language Representations",
														    "ALBERT incorporates two parameter reduction techniques",
														    "The first one is a factorized embedding parameterization. By decomposing the large vocabulary"
														    " embedding matrix into two small matrices, we separate the size of the hidden layers from the size of"
														    " vocabulary embedding.",
														]

														self.assertDictEqual(encoding.data					,   __lowerCAmelCase	)

														for expected, decoded in zip(__lowerCAmelCase					,   __lowerCAmelCase	):
																				self.assertEqual(__lowerCAmelCase					,   __lowerCAmelCase	)







"""simple docstring"""


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


lowerCamelCase__				  =   logging.get_logger(__name__)

lowerCamelCase__				  =   {
    "hustvl/yolos-small": "https://huggingface.co/hustvl/yolos-small/resolve/main/config.json",
    # See all YOLOS models at https://huggingface.co/models?filter=yolos
}



class      __SCREAMING_SNAKE_CASE    (						_UpperCamelCase   ):







  '''simple docstring'''


  SCREAMING_SNAKE_CASE__							:Tuple	     =					"yolos"

  def __init__(		self   :       Dict					,   __a   :       Optional[Any]=768					,   __a   :       List[Any]=12					,   __a   :       Any=12					,   __a   :       List[Any]=3072					,   __a   :       Optional[int]="gelu"					,   __a   :       Dict=0.0					,   __a   :       Optional[Any]=0.0					,   __a   :       Any=0.02					,   __a   :       Optional[int]=1e-1_2					,   __a   :       List[Any]=[512, 864]					,   __a   :       List[str]=16					,   __a   :       str=3					,   __a   :       Optional[Any]=True					,   __a   :       Optional[Any]=100					,   __a   :       List[str]=True					,   __a   :       Any=False					,   __a   :       List[str]=1					,   __a   :       str=5					,   __a   :       Optional[Any]=2					,   __a   :       Tuple=5					,   __a   :       Any=2					,   __a   :       Union[str, Any]=0.1					,   **__a   :       List[str]					,   )		->				List[str]:
        super().__init__(**__a	)

        _UpperCamelCase      :	Dict						=       hidden_size
        _UpperCamelCase      :	Any						=       num_hidden_layers
        _UpperCamelCase      :	str						=       num_attention_heads
        _UpperCamelCase      :	Dict						=       intermediate_size
        _UpperCamelCase      :	List[str]						=       hidden_act
        _UpperCamelCase      :	List[str]						=       hidden_dropout_prob
        _UpperCamelCase      :	str						=       attention_probs_dropout_prob
        _UpperCamelCase      :	Tuple						=       initializer_range
        _UpperCamelCase      :	List[str]						=       layer_norm_eps
        _UpperCamelCase      :	Tuple						=       image_size
        _UpperCamelCase      :	Tuple						=       patch_size
        _UpperCamelCase      :	Dict						=       num_channels
        _UpperCamelCase      :	Any						=       qkv_bias
        _UpperCamelCase      :	str						=       num_detection_tokens
        _UpperCamelCase      :	str						=       use_mid_position_embeddings
        _UpperCamelCase      :	List[str]						=       auxiliary_loss
        # Hungarian matcher
        _UpperCamelCase      :	List[Any]						=       class_cost
        _UpperCamelCase      :	int						=       bbox_cost
        _UpperCamelCase      :	Optional[int]						=       giou_cost
        # Loss coefficients
        _UpperCamelCase      :	List[Any]						=       bbox_loss_coefficient
        _UpperCamelCase      :	str						=       giou_loss_coefficient
        _UpperCamelCase      :	Dict						=       eos_coefficient





class      __SCREAMING_SNAKE_CASE    (						_UpperCamelCase   ):







  '''simple docstring'''


  SCREAMING_SNAKE_CASE__							:List[str]	     =					version.parse("1.11"   )

  @property
  def    __SCREAMING_SNAKE_CASE				(		self   :       str	)		->				Mapping[str, Mapping[int, str]]:
        return OrderedDict(
            [
                ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
            ]	)

  @property
  def    __SCREAMING_SNAKE_CASE				(		self   :       Optional[Any]	)		->				float:
        return 1e-4


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