


import unittest

from transformers.utils.backbone_utils import (
    BackboneMixin,
    get_aligned_output_features_output_indices,
    verify_out_features_out_indices,
)







class  snake_case__(							unittest.TestCase							):







						'''simple docstring'''




						def   lowercase_       ( self							)    ->			Optional[int]:
										lowerCAmelCase_       :					int			 = ["a", "b", "c"]

										# Defaults to last layer if both are None
										lowerCAmelCase_       :					List[str]			 = get_aligned_output_features_output_indices(__lowercase      ,  __lowercase      ,  __lowercase							)
										self.assertEqual(__lowercase      ,  ['''c''']							)
										self.assertEqual(__lowercase      ,  [2]							)

										# Out indices set to match out features
										lowerCAmelCase_       :					str			 = get_aligned_output_features_output_indices(['''a''', '''c''']      ,  __lowercase      ,  __lowercase							)
										self.assertEqual(__lowercase      ,  ['''a''', '''c''']							)
										self.assertEqual(__lowercase      ,  [0, 2]							)

										# Out features set to match out indices
										lowerCAmelCase_       :					Union[str, Any]			 = get_aligned_output_features_output_indices(__lowercase      ,  [0, 2]      ,  __lowercase							)
										self.assertEqual(__lowercase      ,  ['''a''', '''c''']							)
										self.assertEqual(__lowercase      ,  [0, 2]							)

										# Out features selected from negative indices
										lowerCAmelCase_       :					List[str]			 = get_aligned_output_features_output_indices(__lowercase      ,  [-3, -1]      ,  __lowercase							)
										self.assertEqual(__lowercase      ,  ['''a''', '''c''']							)
										self.assertEqual(__lowercase      ,  [-3, -1]							)




						def   lowercase_       ( self							)    ->			Dict:




										with self.assertRaises(__lowercase							):
														verify_out_features_out_indices(['''a''', '''b''']      ,  (0, 1)      ,  __lowercase							)

										# Out features must be a list
										with self.assertRaises(__lowercase							):
														verify_out_features_out_indices(('''a''', '''b''')      ,  (0, 1)      ,  ['''a''', '''b''']							)

										# Out features must be a subset of stage names
										with self.assertRaises(__lowercase							):
														verify_out_features_out_indices(['''a''', '''b''']      ,  (0, 1)      ,  ['''a''']							)

										# Out indices must be a list or tuple
										with self.assertRaises(__lowercase							):
														verify_out_features_out_indices(__lowercase      ,  0      ,  ['''a''', '''b''']							)

										# Out indices must be a subset of stage names
										with self.assertRaises(__lowercase							):
														verify_out_features_out_indices(__lowercase      ,  (0, 1)      ,  ['''a''']							)

										# Out features and out indices must be the same length
										with self.assertRaises(__lowercase							):
														verify_out_features_out_indices(['''a''', '''b''']      ,  (0,)      ,  ['''a''', '''b''', '''c''']							)

										# Out features should match out indices
										with self.assertRaises(__lowercase							):
														verify_out_features_out_indices(['''a''', '''b''']      ,  (0, 2)      ,  ['''a''', '''b''', '''c''']							)

										# Out features and out indices should be in order
										with self.assertRaises(__lowercase							):
														verify_out_features_out_indices(['''b''', '''a''']      ,  (0, 1)      ,  ['''a''', '''b''']							)

										# Check passes with valid inputs
										verify_out_features_out_indices(['''a''', '''b''', '''d''']      ,  (0, 1, -1)      ,  ['''a''', '''b''', '''c''', '''d''']							)




						def   lowercase_       ( self							)    ->			str:
										lowerCAmelCase_       :					Optional[Any]			 = BackboneMixin()

										lowerCAmelCase_       :					List[Any]			 = ["a", "b", "c"]
										lowerCAmelCase_       :					Optional[int]			 = ["a", "c"]
										lowerCAmelCase_       :					List[Any]			 = [0, 2]

										# Check that the output features and indices are set correctly
										self.assertEqual(backbone.out_features      ,  ['''a''', '''c''']							)
										self.assertEqual(backbone.out_indices      ,  [0, 2]							)

										# Check out features and indices are updated correctly
										lowerCAmelCase_       :					Optional[Any]			 = ["a", "b"]
										self.assertEqual(backbone.out_features      ,  ['''a''', '''b''']							)
										self.assertEqual(backbone.out_indices      ,  [0, 1]							)

										lowerCAmelCase_       :					Optional[int]			 = [-3, -1]
										self.assertEqual(backbone.out_features      ,  ['''a''', '''c''']							)
										self.assertEqual(backbone.out_indices      ,  [-3, -1]							)






'''simple docstring'''


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


lowerCAmelCase					:     Optional[Any]												=logging.get_logger(__name__)

lowerCAmelCase					:     Tuple												={
    '''facebook/vit-mae-base''': '''https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json''',
    # See all ViT MAE models at https://huggingface.co/models?filter=vit-mae
}
class       a_   (				_lowerCAmelCase							):
     __A      =			"vit_mae"





     def __init__( self		:					Any	,      lowercase		:					int=768	,      lowercase		:					Tuple=12	,      lowercase		:					str=12	,      lowercase		:					Optional[Any]=3_072	,      lowercase		:					List[Any]="gelu"	,      lowercase		:					Tuple=0.0	,      lowercase		:					Union[str, Any]=0.0	,      lowercase		:					str=0.02	,      lowercase		:					Optional[int]=1e-1_2	,      lowercase		:					List[Any]=224	,      lowercase		:					str=16	,      lowercase		:					List[str]=3	,      lowercase		:					Optional[Any]=True	,      lowercase		:					int=16	,      lowercase		:					Optional[Any]=512	,      lowercase		:					Optional[Any]=8	,      lowercase		:					Optional[Any]=2_048	,      lowercase		:					List[str]=0.75	,      lowercase		:					str=False	,      **lowercase		:					Union[str, Any]	,      ):





        """simple docstring"""




        super().__init__(**lowercase						)

        lowercase_			:Any    			= hidden_size
        lowercase_			:Optional[Any]    			= num_hidden_layers
        lowercase_			:Optional[Any]    			= num_attention_heads
        lowercase_			:int    			= intermediate_size
        lowercase_			:Optional[int]    			= hidden_act
        lowercase_			:str    			= hidden_dropout_prob
        lowercase_			:Optional[Any]    			= attention_probs_dropout_prob
        lowercase_			:str    			= initializer_range
        lowercase_			:Optional[int]    			= layer_norm_eps
        lowercase_			:str    			= image_size
        lowercase_			:Union[str, Any]    			= patch_size
        lowercase_			:Dict    			= num_channels
        lowercase_			:Any    			= qkv_bias
        lowercase_			:Optional[int]    			= decoder_num_attention_heads
        lowercase_			:Optional[Any]    			= decoder_hidden_size
        lowercase_			:Union[str, Any]    			= decoder_num_hidden_layers
        lowercase_			:List[Any]    			= decoder_intermediate_size
        lowercase_			:Optional[Any]    			= mask_ratio
        lowercase_			:Optional[Any]    			= norm_pix_loss


