


'''simple docstring'''




import json
import os
import unittest

from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast
from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES
from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin




@require_tokenizers
class 			_lowercase (	__lowercase						,					unittest.TestCase							):
   _SCREAMING_SNAKE_CASE  :  int          =	OpenAIGPTTokenizer
   _SCREAMING_SNAKE_CASE  :  int          =	OpenAIGPTTokenizerFast
   _SCREAMING_SNAKE_CASE  :  Any          =	True
   _SCREAMING_SNAKE_CASE  :  Tuple          =	False
   def a  (						self       :      List[str]      ) ->							Any:
        super().setUp()

        # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
        __snake_case           =						[
            'l',
            'o',
            'w',
            'e',
            'r',
            's',
            't',
            'i',
            'd',
            'n',
            'w</w>',
            'r</w>',
            't</w>',
            'lo',
            'low',
            'er</w>',
            'low</w>',
            'lowest</w>',
            'newer</w>',
            'wider</w>',
            '<unk>',
        ]
        __snake_case           =						dict(zip(SCREAMING_SNAKE_CASE_       ,   range(len(SCREAMING_SNAKE_CASE_      )      )      )      )
        __snake_case           =						['#version: 0.2', 'l o', 'lo w', 'e r</w>', '']

        __snake_case           =						os.path.join(self.tmpdirname       ,   VOCAB_FILES_NAMES['vocab_file']      )
        __snake_case           =						os.path.join(self.tmpdirname       ,   VOCAB_FILES_NAMES['merges_file']      )
        with open(self.vocab_file       ,   'w'      ) as fp:
             fp.write(json.dumps(SCREAMING_SNAKE_CASE_      )      )
        with open(self.merges_file       ,   'w'      ) as fp:
             fp.write('\n'.join(SCREAMING_SNAKE_CASE_      )      )
   def a  (						self       :      Tuple       ,   SCREAMING_SNAKE_CASE_       :      Dict      ) ->							Optional[Any]:
        return "lower newer", "lower newer"
   def a  (						self       :      List[str]      ) ->							Tuple:
        __snake_case           =						OpenAIGPTTokenizer(self.vocab_file       ,   self.merges_file      )

        __snake_case           =						'lower'
        __snake_case           =						['low', 'er</w>']
        __snake_case           =						tokenizer.tokenize(SCREAMING_SNAKE_CASE_      )
        self.assertListEqual(SCREAMING_SNAKE_CASE_       ,   SCREAMING_SNAKE_CASE_      )

        __snake_case           =						tokens + ['<unk>']
        __snake_case           =						[14, 15, 20]
        self.assertListEqual(tokenizer.convert_tokens_to_ids(SCREAMING_SNAKE_CASE_      )       ,   SCREAMING_SNAKE_CASE_      )
   def a  (						self       :      Optional[int]       ,   SCREAMING_SNAKE_CASE_       :      str=15      ) ->							Optional[Any]:
        for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
             with self.subTest(f'{tokenizer.__class__.__name__} ({pretrained_name})'      ):
                  __snake_case           =						self.rust_tokenizer_class.from_pretrained(SCREAMING_SNAKE_CASE_       ,   **SCREAMING_SNAKE_CASE_      )

                  # Simple input
                  __snake_case           =						'This is a simple input'
                  __snake_case           =						['This is a simple input 1', 'This is a simple input 2']
                  __snake_case           =						('This is a simple input', 'This is a pair')
                  __snake_case           =						[
                      ('This is a simple input 1', 'This is a simple input 2'),
                      ('This is a simple pair 1', 'This is a simple pair 2'),
                  ]

                  # Simple input tests
                  self.assertRaises(SCREAMING_SNAKE_CASE_       ,   tokenizer_r.encode       ,   SCREAMING_SNAKE_CASE_       ,   max_length=SCREAMING_SNAKE_CASE_       ,   padding='max_length'      )

                  # Simple input
                  self.assertRaises(SCREAMING_SNAKE_CASE_       ,   tokenizer_r.encode_plus       ,   SCREAMING_SNAKE_CASE_       ,   max_length=SCREAMING_SNAKE_CASE_       ,   padding='max_length'      )

                  # Simple input
                  self.assertRaises(
                      SCREAMING_SNAKE_CASE_       ,   tokenizer_r.batch_encode_plus       ,   SCREAMING_SNAKE_CASE_       ,   max_length=SCREAMING_SNAKE_CASE_       ,   padding='max_length'       ,   )

                  # Pair input
                  self.assertRaises(SCREAMING_SNAKE_CASE_       ,   tokenizer_r.encode       ,   SCREAMING_SNAKE_CASE_       ,   max_length=SCREAMING_SNAKE_CASE_       ,   padding='max_length'      )

                  # Pair input
                  self.assertRaises(SCREAMING_SNAKE_CASE_       ,   tokenizer_r.encode_plus       ,   SCREAMING_SNAKE_CASE_       ,   max_length=SCREAMING_SNAKE_CASE_       ,   padding='max_length'      )

                  # Pair input
                  self.assertRaises(
                      SCREAMING_SNAKE_CASE_       ,   tokenizer_r.batch_encode_plus       ,   SCREAMING_SNAKE_CASE_       ,   max_length=SCREAMING_SNAKE_CASE_       ,   padding='max_length'       ,   )





   def a  (						self       :      Union[str, Any]      ) ->							Any:
        pass




@require_ftfy
@require_spacy
@require_tokenizers
class 			_lowercase (	__lowercase							):
   pass





"""simple docstring"""






import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING


__lowerCAmelCase       :			Tuple   	=logging.get_logger(__name__)

__lowerCAmelCase       :			Dict   	={
    """ut/deta""": """https://huggingface.co/ut/deta/resolve/main/config.json""",
}





class 					_A		(			lowerCAmelCase      ):
      snake_case__     :  Optional[int]				    =      'deta'
      snake_case__     :  Dict				    =      {
          'hidden_size': 'd_model',
          'num_attention_heads': 'encoder_attention_heads',
      }

      def __init__(		self						,			__lowerCAmelCase=None						,			__lowerCAmelCase=900						,			__lowerCAmelCase=2048						,			__lowerCAmelCase=6						,			__lowerCAmelCase=2048						,			__lowerCAmelCase=8						,			__lowerCAmelCase=6						,			__lowerCAmelCase=1024						,			__lowerCAmelCase=8						,			__lowerCAmelCase=0.0						,			__lowerCAmelCase=True						,			__lowerCAmelCase="relu"						,			__lowerCAmelCase=256						,			__lowerCAmelCase=0.1						,			__lowerCAmelCase=0.0						,			__lowerCAmelCase=0.0						,			__lowerCAmelCase=0.0_2						,			__lowerCAmelCase=1.0						,			__lowerCAmelCase=True						,			__lowerCAmelCase=False						,			__lowerCAmelCase="sine"						,			__lowerCAmelCase=5						,			__lowerCAmelCase=4						,			__lowerCAmelCase=4						,			__lowerCAmelCase=True						,			__lowerCAmelCase=300						,			__lowerCAmelCase=True						,			__lowerCAmelCase=True						,			__lowerCAmelCase=1						,			__lowerCAmelCase=5						,			__lowerCAmelCase=2						,			__lowerCAmelCase=1						,			__lowerCAmelCase=1						,			__lowerCAmelCase=5						,			__lowerCAmelCase=2						,			__lowerCAmelCase=0.1						,			__lowerCAmelCase=0.2_5						,			**__lowerCAmelCase						,			):







            """simple docstring"""



            if backbone_config is None:
                  logger.info("""`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone."""		)
                  lowercase								=      CONFIG_MAPPING["""resnet"""](out_features=["""stage2""", """stage3""", """stage4"""]		)
            else:
                  if isinstance(__lowerCAmelCase						,			__lowerCAmelCase		):
                        lowercase								=      backbone_config.pop("""model_type"""		)
                        lowercase								=      CONFIG_MAPPING[backbone_model_type]
                        lowercase								=      config_class.from_dict(__lowerCAmelCase		)

            lowercase								=      backbone_config
            lowercase								=      num_queries
            lowercase								=      max_position_embeddings
            lowercase								=      d_model
            lowercase								=      encoder_ffn_dim
            lowercase								=      encoder_layers
            lowercase								=      encoder_attention_heads
            lowercase								=      decoder_ffn_dim
            lowercase								=      decoder_layers
            lowercase								=      decoder_attention_heads
            lowercase								=      dropout
            lowercase								=      attention_dropout
            lowercase								=      activation_dropout
            lowercase								=      activation_function
            lowercase								=      init_std
            lowercase								=      init_xavier_std
            lowercase								=      encoder_layerdrop
            lowercase								=      auxiliary_loss
            lowercase								=      position_embedding_type
            # deformable attributes
            lowercase								=      num_feature_levels
            lowercase								=      encoder_n_points
            lowercase								=      decoder_n_points
            lowercase								=      two_stage
            lowercase								=      two_stage_num_proposals
            lowercase								=      with_box_refine
            lowercase								=      assign_first_stage
            if two_stage is True and with_box_refine is False:
                  raise ValueError("""If two_stage is True, with_box_refine must be True."""		)
            # Hungarian matcher
            lowercase								=      class_cost
            lowercase								=      bbox_cost
            lowercase								=      giou_cost
            # Loss coefficients
            lowercase								=      mask_loss_coefficient
            lowercase								=      dice_loss_coefficient
            lowercase								=      bbox_loss_coefficient
            lowercase								=      giou_loss_coefficient
            lowercase								=      eos_coefficient
            lowercase								=      focal_alpha
            super().__init__(is_encoder_decoder=__lowerCAmelCase						,			**__lowerCAmelCase		)

      @property
      def 							A__			(		self		):







            """simple docstring"""



            return self.encoder_attention_heads

      @property
      def 							A__			(		self		):







            """simple docstring"""



            return self.d_model







      def 							A__			(		self		):







            """simple docstring"""



            lowercase								=      copy.deepcopy(self.__dict__		)
            lowercase								=      self.backbone_config.to_dict()
            lowercase								=      self.__class__.model_type
            return output



