



'''simple docstring'''





from typing import TYPE_CHECKING

from ...file_utils import _LazyModule, is_torch_available
from ...utils import OptionalDependencyNotAvailable


__a  			=						{
    "configuration_gpt_neox_japanese": ["GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoXJapaneseConfig"],
    "tokenization_gpt_neox_japanese": ["GPTNeoXJapaneseTokenizer"],
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __a  			=						[
           "GPT_NEOX_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST",
           "GPTNeoXJapaneseForCausalLM",
           "GPTNeoXJapaneseLayer",
           "GPTNeoXJapaneseModel",
           "GPTNeoXJapanesePreTrainedModel",
       ]


if TYPE_CHECKING:
       from .configuration_gpt_neox_japanese import GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTNeoXJapaneseConfig
       from .tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_gpt_neox_japanese import (
                  GPT_NEOX_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST,
                  GPTNeoXJapaneseForCausalLM,
                  GPTNeoXJapaneseLayer,
                  GPTNeoXJapaneseModel,
                  GPTNeoXJapanesePreTrainedModel,
              )


else:
       import sys

       __a  			=						_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





'''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/dinat-mini-in1k-224": "https://huggingface.co/shi-labs/dinat-mini-in1k-224/resolve/main/config.json",
    # See all Dinat models at https://huggingface.co/models?filter=dinat
}







class        UpperCAmelCase_			(			_a						,						_a      ):
    """simple docstring"""







    lowercase   =						"dinat"

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




    def __init__(       self   :	Optional[int]					,	snake_case_   :	Optional[Any]=4					,	snake_case_   :	List[str]=3					,	snake_case_   :	Tuple=64					,	snake_case_   :	List[Any]=[3, 4, 6, 5]					,	snake_case_   :	List[Any]=[2, 4, 8, 16]					,	snake_case_   :	List[str]=7					,	snake_case_   :	List[str]=[[1, 8, 1], [1, 4, 1, 4], [1, 2, 1, 2, 1, 2], [1, 1, 1, 1, 1]]					,	snake_case_   :	List[Any]=3.0					,	snake_case_   :	Dict=True					,	snake_case_   :	int=0.0					,	snake_case_   :	Optional[int]=0.0					,	snake_case_   :	str=0.1					,	snake_case_   :	Optional[Any]="gelu"					,	snake_case_   :	Union[str, Any]=0.02					,	snake_case_   :	Optional[int]=1E-5					,	snake_case_   :	str=0.0					,	snake_case_   :	Dict=None					,	snake_case_   :	Dict=None					,	**snake_case_   :	Dict					,	):
          super().__init__(**snake_case_		)

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