






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


A__	:    Optional[int]			 = logging.get_logger(__name__)

A__	:    Optional[int]			 = {
    '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        lowercase__      (							UpperCamelCase__,       UpperCamelCase__       ):
			_UpperCAmelCase		:Tuple             =			'''dinat'''

			_UpperCAmelCase		:List[str]             =			{
			    '''num_attention_heads''': '''num_heads''',
			    '''num_hidden_layers''': '''num_layers''',
			}


			def __init__(				self					:  List[Any]       ,	snake_case__					:  List[Any]=4       ,	snake_case__					:  Dict=3       ,	snake_case__					:  str=64       ,	snake_case__					:  Dict=[3, 4, 6, 5]       ,	snake_case__					:  Optional[int]=[2, 4, 8, 16]       ,	snake_case__					:  Tuple=7       ,	snake_case__					:  Dict=[[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__					:  str=0.0       ,	snake_case__					:  Any=0.0       ,	snake_case__					:  int=0.1       ,	snake_case__					:  Optional[Any]="gelu"       ,	snake_case__					:  Optional[Any]=0.02       ,	snake_case__					:  Optional[Any]=1E-5       ,	snake_case__					:  Tuple=0.0       ,	snake_case__					:  Optional[int]=None       ,	snake_case__					:  List[str]=None       ,	**snake_case__					:  int       ,	):
										super().__init__(**UpperCamelCase_ )

										lowerCamelCase_	:							Dict									=patch_size
										lowerCamelCase_	:							str									=num_channels
										lowerCamelCase_	:							List[Any]									=embed_dim
										lowerCamelCase_	:							List[str]									=depths
										lowerCamelCase_	:							List[str]									=len(UpperCamelCase_ )
										lowerCamelCase_	:							Tuple									=num_heads
										lowerCamelCase_	:							Dict									=kernel_size
										lowerCamelCase_	:							int									=dilations
										lowerCamelCase_	:							List[str]									=mlp_ratio
										lowerCamelCase_	:							Dict									=qkv_bias
										lowerCamelCase_	:							Any									=hidden_dropout_prob
										lowerCamelCase_	:							Tuple									=attention_probs_dropout_prob
										lowerCamelCase_	:							Union[str, Any]									=drop_path_rate
										lowerCamelCase_	:							List[str]									=hidden_act
										lowerCamelCase_	:							Optional[Any]									=layer_norm_eps
										lowerCamelCase_	:							Optional[int]									=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
										lowerCamelCase_	:							Optional[int]									=int(embed_dim * 2 ** (len(UpperCamelCase_ ) - 1) )
										lowerCamelCase_	:							Any									=layer_scale_init_value
										lowerCamelCase_	:							Tuple									=["stem"] + [F"""stage{idx}""" for idx in range(1       ,	len(UpperCamelCase_ ) + 1 )]
										lowerCamelCase_							,						lowerCamelCase_	:							str									=get_aligned_output_features_output_indices(
										    out_features=UpperCamelCase_       ,	out_indices=UpperCamelCase_       ,	stage_names=self.stage_names )











"""simple docstring"""



import pytest

from datasets.parallel import ParallelBackendConfig, parallel_backend
from datasets.utils.py_utils import map_nested

from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows

def 			_snake_case    (					lowerCamelCase__     :   Any  )    ->     Union[str, Any]:  # picklable for multiprocessing
							return i + 1

@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def 			_snake_case    (					)    ->     List[Any]:
							with parallel_backend("spark"  ):
														assert ParallelBackendConfig.backend_name == "spark"

							lowerCamelCase_	:							Optional[Any]									=[1, 2, 3]
							with pytest.raises(lowerCamelCase__  ):
														with parallel_backend("unsupported backend"  ):
																					map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=2  )

							with pytest.raises(lowerCamelCase__  ):
														with parallel_backend("unsupported backend"  ):
																					map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=-1  )

@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize("num_proc"    ,						[2, -1]  )
def 			_snake_case    (					lowerCamelCase__     :   Tuple  )    ->     Optional[Any]:
							lowerCamelCase_	:							str									=[1, 2]
							lowerCamelCase_	:							List[str]									={"a": 1, "b": 2}
							lowerCamelCase_	:							List[str]									={"a": [1, 2], "b": [3, 4]}
							lowerCamelCase_	:							Optional[int]									={"a": {"1": 1}, "b": 2}
							lowerCamelCase_	:							int									={"a": 1, "b": 2, "c": 3, "d": 4}
							lowerCamelCase_	:							Optional[int]									=[2, 3]
							lowerCamelCase_	:							List[Any]									={"a": 2, "b": 3}
							lowerCamelCase_	:							int									={"a": [2, 3], "b": [4, 5]}
							lowerCamelCase_	:							str									={"a": {"1": 2}, "b": 3}
							lowerCamelCase_	:							Dict									={"a": 2, "b": 3, "c": 4, "d": 5}

							with parallel_backend("spark"  ):
														assert map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=lowerCamelCase__  ) == expected_map_nested_sa
														assert map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=lowerCamelCase__  ) == expected_map_nested_sa
														assert map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=lowerCamelCase__  ) == expected_map_nested_sa
														assert map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=lowerCamelCase__  ) == expected_map_nested_sa
														assert map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=lowerCamelCase__  ) == expected_map_nested_sa



