'''simple docstring'''






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


__a										=					logging.get_logger(__name__)

__a										=					{
    """facebook/convnextv2-tiny-1k-224""": """https://huggingface.co/facebook/convnextv2-tiny-1k-224/resolve/main/config.json""",
}





class     A__							(       __snake_case					,		__snake_case   ):





   """simple docstring"""





   UpperCamelCase_       :						Optional[int]    				=     'convnextv2'




   def __init__( self     :		Optional[Any]						,     lowerCAmelCase__     :		List[str]=3						,     lowerCAmelCase__     :		List[str]=4						,     lowerCAmelCase__     :		Optional[int]=4						,     lowerCAmelCase__     :		Dict=None						,     lowerCAmelCase__     :		Optional[Any]=None						,     lowerCAmelCase__     :		Any="gelu"						,     lowerCAmelCase__     :		Dict=0.02						,     lowerCAmelCase__     :		Optional[int]=1e-12						,     lowerCAmelCase__     :		Optional[Any]=0.0						,     lowerCAmelCase__     :		Dict=2_2_4						,     lowerCAmelCase__     :		Dict=None						,     lowerCAmelCase__     :		List[str]=None						,     **lowerCAmelCase__     :		Any						,     )       ->    Any:







      """simple docstring"""




      super().__init__(**A_			)

      _UpperCAmelCase							:	Dict							=   num_channels
      _UpperCAmelCase							:	Union[str, Any]							=   patch_size
      _UpperCAmelCase							:	Union[str, Any]							=   num_stages
      _UpperCAmelCase							:	List[Any]							=   [9_6, 1_9_2, 3_8_4, 7_6_8] if hidden_sizes is None else hidden_sizes
      _UpperCAmelCase							:	List[str]							=   [3, 3, 9, 3] if depths is None else depths
      _UpperCAmelCase							:	Dict							=   hidden_act
      _UpperCAmelCase							:	Union[str, Any]							=   initializer_range
      _UpperCAmelCase							:	Tuple							=   layer_norm_eps
      _UpperCAmelCase							:	str							=   drop_path_rate
      _UpperCAmelCase							:	List[str]							=   image_size
      _UpperCAmelCase							:	List[str]							=   ["stem"] + [F"""stage{idx}""" for idx in range(1						,     len(self.depths			) + 1			)]
      _UpperCAmelCase							:	str							=   get_aligned_output_features_output_indices(
          out_features=A_						,     out_indices=A_						,     stage_names=self.stage_names			)






class 					A__   :





      def __init__( self       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Union[str, Any]       	=   set_counts
       UpperCamelCase	:					int       	=   max(A_   )
       UpperCamelCase	:					Optional[Any]       	=   len(A_   )
       UpperCamelCase	:					Union[str, Any]       	=   [1] * num_sets
       UpperCamelCase	:					Union[str, Any]       	=   list(range(A_   )   )





      def        __UpperCamelCase( self       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Any       	=   self.get_parent(A_   )
       UpperCamelCase	:					Optional[int]       	=   self.get_parent(A_   )

       if src_parent == dst_parent:
        return False

       if self.ranks[dst_parent] >= self.ranks[src_parent]:
        self.set_counts[dst_parent] += self.set_counts[src_parent]
        UpperCamelCase	:					int       	=   0
        UpperCamelCase	:					Dict       	=   dst_parent
        if self.ranks[dst_parent] == self.ranks[src_parent]:
         self.ranks[dst_parent] += 1
        UpperCamelCase	:					Optional[int]       	=   self.set_counts[dst_parent]
       else:
        self.set_counts[src_parent] += self.set_counts[dst_parent]
        UpperCamelCase	:					Any       	=   0
        UpperCamelCase	:					Optional[int]       	=   src_parent
        UpperCamelCase	:					int       	=   self.set_counts[src_parent]

       UpperCamelCase	:					Any       	=   max(self.max_set       ,							A_   )
       return True





      def        __UpperCamelCase( self       ,							A_   ):
       '''simple docstring'''




       if self.parents[disj_set] == disj_set:
        return disj_set
       UpperCamelCase	:					Optional[int]       	=   self.get_parent(self.parents[disj_set]   )
       return self.parents[disj_set]
