



'''simple docstring'''





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				):
 def A_   (   self						:							List[Any]  )      ->   List[Any]:







       '''simple docstring'''
       __snake_case :   Optional[int]													=    ['a', 'b', 'c']

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

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

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

       # Out features selected from negative indices
       __snake_case							,     __snake_case :   Dict													=    get_aligned_output_features_output_indices(__a      ,     [-3, -1]      ,     __a  )
       self.assertEqual(__a      ,     ['a', 'c']  )
       self.assertEqual(__a      ,     [-3, -1]  )
 def A_   (   self						:							Optional[int]  )      ->   Optional[Any]:







       '''simple docstring'''
       # Stage names must be set
       with self.assertRaises(__a  ):
             verify_out_features_out_indices(['a', 'b']      ,     (0, 1)      ,     __a  )

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

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

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

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

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

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

       # Out features and out indices should be in order
       with self.assertRaises(__a  ):
             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 A_   (   self						:							Optional[int]  )      ->   List[Any]:







       '''simple docstring'''
       __snake_case :   Optional[int]													=    BackboneMixin()

       __snake_case :   Any													=    ['a', 'b', 'c']
       __snake_case :   Union[str, Any]													=    ['a', 'c']
       __snake_case :   List[str]													=    [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
       __snake_case :   str													=    ['a', 'b']
       self.assertEqual(backbone.out_features      ,     ['a', 'b']  )
       self.assertEqual(backbone.out_indices      ,     [0, 1]  )

       __snake_case :   Any													=    [-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


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

A__    :   List[str]           =					{
    '''microsoft/cvt-13''': '''https://huggingface.co/microsoft/cvt-13/resolve/main/config.json''',
    # See all Cvt models at https://huggingface.co/models?filter=cvt
}



class  snake_case__						(    SCREAMING_SNAKE_CASE_				):
 A__				= '''cvt'''
 def __init__(   self						:							Optional[Any]      ,     __a						:							Union[str, Any]=3      ,     __a						:							List[Any]=[7, 3, 3]      ,     __a						:							Optional[int]=[4, 2, 2]      ,     __a						:							Dict=[2, 1, 1]      ,     __a						:							Union[str, Any]=[64, 192, 384]      ,     __a						:							int=[1, 3, 6]      ,     __a						:							List[str]=[1, 2, 10]      ,     __a						:							Optional[Any]=[4.0, 4.0, 4.0]      ,     __a						:							Any=[0.0, 0.0, 0.0]      ,     __a						:							List[str]=[0.0, 0.0, 0.0]      ,     __a						:							List[Any]=[0.0, 0.0, 0.1]      ,     __a						:							List[str]=[True, True, True]      ,     __a						:							int=[False, False, True]      ,     __a						:							Dict=["dw_bn", "dw_bn", "dw_bn"]      ,     __a						:							List[str]=[3, 3, 3]      ,     __a						:							Union[str, Any]=[1, 1, 1]      ,     __a						:							Optional[int]=[2, 2, 2]      ,     __a						:							Optional[Any]=[1, 1, 1]      ,     __a						:							List[str]=[1, 1, 1]      ,     __a						:							List[str]=0.0_2      ,     __a						:							List[str]=1e-12      ,     **__a						:							List[str]      ,     )      ->   Dict:







       '''simple docstring'''
       super().__init__(**__a  )
       __snake_case :   int													=    num_channels
       __snake_case :   Union[str, Any]													=    patch_sizes
       __snake_case :   Any													=    patch_stride
       __snake_case :   List[str]													=    patch_padding
       __snake_case :   Optional[Any]													=    embed_dim
       __snake_case :   Union[str, Any]													=    num_heads
       __snake_case :   Dict													=    depth
       __snake_case :   Optional[Any]													=    mlp_ratio
       __snake_case :   List[str]													=    attention_drop_rate
       __snake_case :   Optional[int]													=    drop_rate
       __snake_case :   Optional[int]													=    drop_path_rate
       __snake_case :   Any													=    qkv_bias
       __snake_case :   int													=    cls_token
       __snake_case :   Optional[int]													=    qkv_projection_method
       __snake_case :   List[Any]													=    kernel_qkv
       __snake_case :   List[Any]													=    padding_kv
       __snake_case :   int													=    stride_kv
       __snake_case :   List[str]													=    padding_q
       __snake_case :   Dict													=    stride_q
       __snake_case :   Tuple													=    initializer_range
       __snake_case :   List[Any]													=    layer_norm_eps



