

'''simple docstring'''

from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCAmelCase					 =	logging.get_logger(__name__)

UpperCAmelCase					 =	{
    '''facebook/nllb-moe-54B''': '''https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json''',
}


class 	lowerCAmelCase  (   A ):
       lowerCAmelCase_												=			"nllb-moe"
       lowerCAmelCase_												=			["past_key_values"]
       lowerCAmelCase_												=			{"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}







       def __init__(				self      :			Optional[int]    ,   __lowercase      :			List[Any]=128112    ,   __lowercase      :			int=1024    ,   __lowercase      :			Any=12    ,   __lowercase      :			Any=4096    ,   __lowercase      :			Optional[Any]=16    ,   __lowercase      :			List[str]=12    ,   __lowercase      :			str=4096    ,   __lowercase      :			int=16    ,   __lowercase      :			str=0.0_5    ,   __lowercase      :			Optional[Any]=0.0_5    ,   __lowercase      :			Tuple=True    ,   __lowercase      :			Optional[int]=True    ,   __lowercase      :			Union[str, Any]="relu"    ,   __lowercase      :			Any=1024    ,   __lowercase      :			Optional[Any]=0.1    ,   __lowercase      :			int=0.1    ,   __lowercase      :			str=0.0    ,   __lowercase      :			Optional[Any]=0.0_2    ,   __lowercase      :			Union[str, Any]=2    ,   __lowercase      :			Optional[int]=True    ,   __lowercase      :			List[str]=False    ,   __lowercase      :			List[str]="float32"    ,   __lowercase      :			Dict=False    ,   __lowercase      :			List[str]=128    ,   __lowercase      :			Union[str, Any]=64    ,   __lowercase      :			Any=4    ,   __lowercase      :			Optional[Any]=4    ,   __lowercase      :			str=0.0_0_1    ,   __lowercase      :			str=0.0_0_1    ,   __lowercase      :			Dict="all"    ,   __lowercase      :			int=False    ,   __lowercase      :			Optional[Any]=False    ,   __lowercase      :			List[str]=1.0    ,   __lowercase      :			Dict=0.2    ,   __lowercase      :			List[Any]=1    ,   __lowercase      :			Optional[int]=0    ,   __lowercase      :			str=2    ,   __lowercase      :			Optional[Any]=False    ,   **__lowercase      :			Dict    ,   ):







            """simple docstring"""







            __lowercase      		=vocab_size
            __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      		=encoder_layerdrop
            __lowercase      		=decoder_layerdrop
            __lowercase      		=use_cache
            __lowercase      		=encoder_layers
            __lowercase      		=scale_embedding  # scale factor will be sqrt(d_model) if True
            __lowercase      		=router_z_loss_coef
            __lowercase      		=router_aux_loss_coef
            __lowercase      		=decoder_sparse_step
            __lowercase      		=encoder_sparse_step
            __lowercase      		=num_experts
            __lowercase      		=expert_capacity
            __lowercase      		=router_bias
            if router_dtype not in ["float32", "float16", "bfloat16"]:
                 raise ValueError(f'''`router_dtype` must be one of \'float32\', \'float16\' or \'bfloat16\', got {router_dtype}'''   )
            __lowercase      		=router_dtype

            __lowercase      		=router_ignore_padding_tokens
            __lowercase      		=batch_prioritized_routing
            __lowercase      		=second_expert_policy
            __lowercase      		=normalize_router_prob_before_dropping
            __lowercase      		=moe_eval_capacity_token_fraction
            __lowercase      		=moe_token_dropout
            __lowercase      		=output_router_logits
            super().__init__(
                pad_token_id=__lowercase    ,   bos_token_id=__lowercase    ,   eos_token_id=__lowercase    ,   is_encoder_decoder=__lowercase    ,   decoder_start_token_id=__lowercase    ,   **__lowercase    ,   )





'''simple docstring'''

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


UpperCAmelCase					 =	logging.get_logger(__name__)

UpperCAmelCase					 =	{
    '''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 	lowerCAmelCase  (   A ,      A ):
       lowerCAmelCase_												=			"dinat"

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







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







            """simple docstring"""







            super().__init__(**__lowercase   )

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


