





'''simple docstring'''


import json
import os
import unittest

from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer

from ...test_tokenization_common import TokenizerTesterMixin






class     lowerCAmelCase__ (				UpperCAmelCase_      , unittest.TestCase    ):

       '''simple docstring'''
       _lowerCamelCase								=CTRLTokenizer
       _lowerCamelCase								=False
       _lowerCamelCase								=False

       def 			__snake_case      ( self					:				List[str]						):
              super().setUp()

              # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
              UpperCAmelCase  =						['''adapt''', '''re@@''', '''a@@''', '''apt''', '''c@@''', '''t''', '''<unk>''']
              UpperCAmelCase  =						dict(zip(a__       ,     range(len(a__						)						)						)						)
              UpperCAmelCase  =						['''#version: 0.2''', '''a p''', '''ap t</w>''', '''r e''', '''a d''', '''ad apt</w>''', '''''']
              UpperCAmelCase  =						{'''unk_token''': '''<unk>'''}

              UpperCAmelCase  =						os.path.join(self.tmpdirname       ,     VOCAB_FILES_NAMES['''vocab_file''']						)
              UpperCAmelCase  =						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(a__						) + '''\n'''						)
              with open(self.merges_file       ,     '''w'''       ,     encoding='''utf-8'''						) as fp:
                     fp.write('''\n'''.join(a__						)						)

       def 			__snake_case      ( self					:				Union[str, Any]       ,     **a__					:				int						):
              kwargs.update(self.special_tokens_map						)
              return CTRLTokenizer.from_pretrained(self.tmpdirname       ,     **a__						)

       def 			__snake_case      ( self					:				List[str]       ,     a__					:				List[Any]						):
              UpperCAmelCase  =						'''adapt react readapt apt'''
              UpperCAmelCase  =						'''adapt react readapt apt'''
              return input_text, output_text



       def 			__snake_case      ( self					:				int						):
              UpperCAmelCase  =						CTRLTokenizer(self.vocab_file       ,     self.merges_file       ,     **self.special_tokens_map						)
              UpperCAmelCase  =						'''adapt react readapt apt'''
              UpperCAmelCase  =						'''adapt re@@ a@@ c@@ t re@@ adapt apt'''.split()
              UpperCAmelCase  =						tokenizer.tokenize(a__						)
              self.assertListEqual(a__       ,     a__						)

              UpperCAmelCase  =						tokens + [tokenizer.unk_token]

              UpperCAmelCase  =						[0, 1, 2, 4, 5, 1, 0, 3, 6]
              self.assertListEqual(tokenizer.convert_tokens_to_ids(a__						)       ,     a__						)






from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


lowerCamelCase		   =			logging.get_logger(__name__)

lowerCamelCase		   =			{
    'microsoft/focalnet-tiny': 'https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json',
}




class A    (  UpperCamelCase_       ,				UpperCamelCase_	):
      UpperCamelCase__				:    str ='focalnet'






      def __init__(   self		:	Optional[int]     ,  lowercase_		:	List[Any]=224     ,  lowercase_		:	str=4     ,  lowercase_		:	Any=3     ,  lowercase_		:	Dict=96     ,  lowercase_		:	List[str]=False     ,  lowercase_		:	Any=[192, 384, 768, 768]     ,  lowercase_		:	Dict=[2, 2, 6, 2]     ,  lowercase_		:	Optional[int]=[2, 2, 2, 2]     ,  lowercase_		:	List[Any]=[3, 3, 3, 3]     ,  lowercase_		:	Any="gelu"     ,  lowercase_		:	str=4.0     ,  lowercase_		:	List[Any]=0.0     ,  lowercase_		:	Tuple=0.1     ,  lowercase_		:	Optional[Any]=False     ,  lowercase_		:	Optional[int]=1E-4     ,  lowercase_		:	Dict=False     ,  lowercase_		:	Optional[Any]=False     ,  lowercase_		:	Dict=False     ,  lowercase_		:	List[Any]=0.02     ,  lowercase_		:	Any=1E-5     ,  lowercase_		:	Any=32     ,  lowercase_		:	List[str]=None     ,  lowercase_		:	int=None     ,  **lowercase_		:	Optional[Any]     ,  )   ->		Optional[Any]:
             """simple docstring"""




             super().__init__(**lowercase_					)

             _lowerCamelCase			:						Union[str, Any]            =image_size
             _lowerCamelCase			:						str            =patch_size
             _lowerCamelCase			:						str            =num_channels
             _lowerCamelCase			:						Tuple            =embed_dim
             _lowerCamelCase			:						Dict            =use_conv_embed
             _lowerCamelCase			:						int            =hidden_sizes
             _lowerCamelCase			:						str            =depths
             _lowerCamelCase			:						int            =focal_levels
             _lowerCamelCase			:						List[Any]            =focal_windows
             _lowerCamelCase			:						List[Any]            =hidden_act
             _lowerCamelCase			:						int            =mlp_ratio
             _lowerCamelCase			:						Any            =hidden_dropout_prob
             _lowerCamelCase			:						Optional[Any]            =drop_path_rate
             _lowerCamelCase			:						int            =use_layerscale
             _lowerCamelCase			:						str            =layerscale_value
             _lowerCamelCase			:						Dict            =use_post_layernorm
             _lowerCamelCase			:						str            =use_post_layernorm_in_modulation
             _lowerCamelCase			:						List[Any]            =normalize_modulator
             _lowerCamelCase			:						Optional[Any]            =initializer_range
             _lowerCamelCase			:						List[str]            =layer_norm_eps
             _lowerCamelCase			:						Optional[int]            =encoder_stride
             _lowerCamelCase			:						List[str]            =['stem'] + [F'''stage{idx}''' for idx in range(1     ,  len(self.depths					) + 1					)]
             _lowerCamelCase      ,	_lowerCamelCase			:						Union[str, Any]            =get_aligned_output_features_output_indices(
                 out_features=lowercase_     ,  out_indices=lowercase_     ,  stage_names=self.stage_names					)


