





'''simple docstring'''


import unittest

from transformers.utils.backbone_utils import (
    BackboneMixin,
    get_aligned_output_features_output_indices,
    verify_out_features_out_indices,
)
class       a_   (				unittest.TestCase							):





     def 							lowercase__      ( self		:					Tuple						):





        """simple docstring"""




        lowercase_			:int    			= ["a", "b", "c"]

        # Defaults to last layer if both are None
        lowercase_			,							lowercase_			: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
        lowercase_			,							lowercase_			: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
        lowercase_			,							lowercase_			: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
        lowercase_			,							lowercase_			: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		:					List[Any]						):





        """simple docstring"""




        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		:					Tuple						):





        """simple docstring"""




        lowercase_			:Optional[Any]    			= BackboneMixin()

        lowercase_			:List[Any]    			= ["a", "b", "c"]
        lowercase_			:Optional[int]    			= ["a", "c"]
        lowercase_			: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
        lowercase_			:Optional[Any]    			= ["a", "b"]
        self.assertEqual(backbone.out_features	,      ["a", "b"]						)
        self.assertEqual(backbone.out_indices	,      [0, 1]						)

        lowercase_			: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


