





"""simple docstring"""






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_			=							{
    '''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 	lowerCAmelCase					(      snake_case			,	snake_case							):
							lowerCAmelCase__						 =  """nat"""

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






							def __init__(   self    ,  a__=4    ,  a__=3    ,  a__=64    ,  a__=[3, 4, 6, 5]    ,  a__=[2, 4, 8, 16]    ,  a__=7    ,  a__=3.0    ,  a__=True    ,  a__=0.0    ,  a__=0.0    ,  a__=0.1    ,  a__="gelu"    ,  a__=0.02    ,  a__=1E-5    ,  a__=0.0    ,  a__=None    ,  a__=None    ,  **a__    ,  ):
														super().__init__(**a__     )

														_UpperCAmelCase     =     patch_size
														_UpperCAmelCase     =     num_channels
														_UpperCAmelCase     =     embed_dim
														_UpperCAmelCase     =     depths
														_UpperCAmelCase     =     len(a__     )
														_UpperCAmelCase     =     num_heads
														_UpperCAmelCase     =     kernel_size
														_UpperCAmelCase     =     mlp_ratio
														_UpperCAmelCase     =     qkv_bias
														_UpperCAmelCase     =     hidden_dropout_prob
														_UpperCAmelCase     =     attention_probs_dropout_prob
														_UpperCAmelCase     =     drop_path_rate
														_UpperCAmelCase     =     hidden_act
														_UpperCAmelCase     =     layer_norm_eps
														_UpperCAmelCase     =     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
														_UpperCAmelCase     =     int(embed_dim * 2 ** (len(a__     ) - 1)     )
														_UpperCAmelCase     =     layer_scale_init_value
														_UpperCAmelCase     =     ['stem'] + [f"""stage{idx}""" for idx in range(1    ,  len(a__     ) + 1     )]
														_UpperCAmelCase    ,							_UpperCAmelCase     =     get_aligned_output_features_output_indices(
														    out_features=a__    ,  out_indices=a__    ,  stage_names=self.stage_names     )













"""simple docstring"""






# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowerCAmelCase_			=							{'''configuration_timm_backbone''': ['''TimmBackboneConfig''']}


try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowerCAmelCase_			=							['''TimmBackbone''']


if TYPE_CHECKING:
    from .configuration_timm_backbone import TimmBackboneConfig

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_timm_backbone import TimmBackbone

else:
    import sys

    lowerCAmelCase_			=							_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)






