




# Lint as: python3
import itertools
import os
import re


UpperCAmelCase_									=	re.compile(r'([A-Z]+)([A-Z][a-z])')
UpperCAmelCase_									=	re.compile(r'([a-z\d])([A-Z])')

UpperCAmelCase_									=	re.compile(r'(?<!_)_(?!_)')
UpperCAmelCase_									=	re.compile(r'(_{2,})')

UpperCAmelCase_									=	r'^\w+(\.\w+)*$'

UpperCAmelCase_									=	r'<>:/\|?*'




def 					lowerCamelCase__       (						A__       :					Dict	):





       '''simple docstring'''



       __lowerCamelCase   =						_uppercase_uppercase_re.sub(R"""\1_\2"""  ,			A__	)
       __lowerCamelCase   =						_lowercase_uppercase_re.sub(R"""\1_\2"""  ,			A__	)
       return name.lower()




def 					lowerCamelCase__       (						A__       :					str	):





       '''simple docstring'''



       __lowerCamelCase   =						_single_underscore_re.split(A__	)
       __lowerCamelCase   =						[_multiple_underscores_re.split(A__	) for n in name]
       return "".join(n.capitalize() for n in itertools.chain.from_iterable(A__	) if n != """"""	)




def 					lowerCamelCase__       (						A__       :					Optional[Any]	):





       '''simple docstring'''



       if os.path.basename(A__	) != name:
              raise ValueError(f'Should be a dataset name, not a path: {name}'	)
       return camelcase_to_snakecase(A__	)




def 					lowerCamelCase__       (						A__       :					Dict  ,			A__       :					Dict	):





       '''simple docstring'''



       if os.path.basename(A__	) != name:
              raise ValueError(f'Should be a dataset name, not a path: {name}'	)
       if not re.match(_split_re  ,			A__	):
              raise ValueError(f'Split name should match \'{_split_re}\'\' but got \'{split}\'.'	)
       return f'{filename_prefix_for_name(A__	)}-{split}'




def 					lowerCamelCase__       (						A__       :					int  ,			A__       :					Tuple  ,			A__       :					Optional[Any]  ,			A__       :					str=None	):





       '''simple docstring'''



       __lowerCamelCase   =						filename_prefix_for_split(A__  ,			A__	)
       if filetype_suffix:
              prefix += f'.{filetype_suffix}'
       __lowerCamelCase   =						os.path.join(A__  ,			A__	)
       return f'{filepath}*'




def 					lowerCamelCase__       (						A__       :					List[str]  ,			A__       :					List[Any]  ,			A__       :					int  ,			A__       :					int=None  ,			A__       :					Any=None	):





       '''simple docstring'''



       __lowerCamelCase   =						filename_prefix_for_split(A__  ,			A__	)
       __lowerCamelCase   =						os.path.join(A__  ,			A__	)

       if shard_lengths:
              __lowerCamelCase   =						len(A__	)
              __lowerCamelCase   =						[f'{prefix}-{shard_id:05d}-of-{num_shards:05d}' for shard_id in range(A__	)]
              if filetype_suffix:
                     __lowerCamelCase   =						[filename + f'.{filetype_suffix}' for filename in filenames]
              return filenames
       else:
              __lowerCamelCase   =						prefix
              if filetype_suffix:
                     filename += f'.{filetype_suffix}'
              return [filename]








"""simple docstring"""



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


a_ =			logging.get_logger(__name__)

a_ =			{
    """shi-labs/nat-mini-in1k-224""": """https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json""",
    # See all Nat models at https://huggingface.co/models?filter=nat
}






class 		__snake_case					(		SCREAMING_SNAKE_CASE__							,							SCREAMING_SNAKE_CASE__     ):





 """simple docstring"""


 _lowerCamelCase        =     """nat"""

 _lowerCamelCase        =     {
     """num_attention_heads""": """num_heads""",
     """num_hidden_layers""": """num_layers""",
 }

 def __init__(    self					,						__lowerCamelCase=4					,						__lowerCamelCase=3					,						__lowerCamelCase=64					,						__lowerCamelCase=[3, 4, 6, 5]					,						__lowerCamelCase=[2, 4, 8, 16]					,						__lowerCamelCase=7					,						__lowerCamelCase=3.0					,						__lowerCamelCase=True					,						__lowerCamelCase=0.0					,						__lowerCamelCase=0.0					,						__lowerCamelCase=0.1					,						__lowerCamelCase="gelu"					,						__lowerCamelCase=0.0_2					,						__lowerCamelCase=1e-5					,						__lowerCamelCase=0.0					,						__lowerCamelCase=None					,						__lowerCamelCase=None					,						**__lowerCamelCase					,						):



     '''simple docstring'''




     super().__init__(**__lowerCamelCase  )

     __A    :						Union[str, Any]						 =     patch_size
     __A    :						Optional[Any]						 =     num_channels
     __A    :						Tuple						 =     embed_dim
     __A    :						Dict						 =     depths
     __A    :						str						 =     len(__lowerCamelCase  )
     __A    :						Optional[Any]						 =     num_heads
     __A    :						str						 =     kernel_size
     __A    :						Any						 =     mlp_ratio
     __A    :						Optional[int]						 =     qkv_bias
     __A    :						str						 =     hidden_dropout_prob
     __A    :						Any						 =     attention_probs_dropout_prob
     __A    :						int						 =     drop_path_rate
     __A    :						int						 =     hidden_act
     __A    :						Any						 =     layer_norm_eps
     __A    :						Tuple						 =     initializer_range
     # we set the hidden_size attribute in order to make Nat work with VisionEncoderDecoderModel
     # this indicates the channel dimension after the last stage of the model
     __A    :						int						 =     int(embed_dim * 2 ** (len(__lowerCamelCase  ) - 1)  )
     __A    :						Union[str, Any]						 =     layer_scale_init_value
     __A    :						List[str]						 =     ['''stem'''] + [F"""stage{idx}""" for idx in range(1					,						len(__lowerCamelCase  ) + 1  )]
     __A ,       __A    :						Any						 =     get_aligned_output_features_output_indices(
         out_features=__lowerCamelCase					,						out_indices=__lowerCamelCase					,						stage_names=self.stage_names  )




