





'''simple docstring'''

def 					a__				(				lowercase					:     Tuple      )		->		Tuple:





     """simple docstring"""

     _UpperCamelCase				    =       0
     _UpperCamelCase				    =       len(_lowerCAmelCase      )

     for i in range(n - 1      ):
          for j in range(i + 1,					_lowerCAmelCase      ):
               if arr[i] > arr[j]:
                    num_inversions += 1

     return num_inversions







def 					a__				(				lowercase					:     List[Any]      )		->		Optional[int]:





     """simple docstring"""

     if len(_lowerCAmelCase      ) <= 1:
          return arr, 0
     _UpperCamelCase				    =       len(_lowerCAmelCase      ) // 2
     _UpperCamelCase				    =       arr[0:mid]
     _UpperCamelCase				    =       arr[mid:]

     _UpperCamelCase				    =       count_inversions_recursive(_lowerCAmelCase      )
     _UpperCamelCase				    =       count_inversions_recursive(_lowerCAmelCase      )
     _UpperCamelCase				    =       _count_cross_inversions(_lowerCAmelCase,					_lowerCAmelCase      )

     _UpperCamelCase				    =       inversion_p + inversions_q + cross_inversions
     return c, num_inversions







def 					a__				(				lowercase					:     Optional[Any],					lowercase					:     Any      )		->		int:





     """simple docstring"""

     _UpperCamelCase				    =       []
     _UpperCamelCase				    =       0
     while i < len(_lowerCAmelCase      ) and j < len(_lowerCAmelCase      ):
          if p[i] > q[j]:
               # if P[1] > Q[j], then P[k] > Q[k] for all  i < k <= len(P)
               # These are all inversions. The claim emerges from the
               # property that P is sorted.
               num_inversion += len(_lowerCAmelCase      ) - i
               r.append(q[j]      )
               j += 1
          else:
               r.append(p[i]      )
               i += 1

     if i < len(_lowerCAmelCase      ):
          r.extend(p[i:]      )
     else:
          r.extend(q[j:]      )

     return r, num_inversion







def 					a__				(				)		->		Dict:





     """simple docstring"""

     _UpperCamelCase				    =       [10, 2, 1, 5, 5, 2, 11]

     # this arr has 8 inversions:
     # (10, 2), (10, 1), (10, 5), (10, 5), (10, 2), (2, 1), (5, 2), (5, 2)

     _UpperCamelCase				    =       count_inversions_bf(_lowerCAmelCase      )
     _UpperCamelCase				    =       count_inversions_recursive(_lowerCAmelCase      )

     assert num_inversions_bf == num_inversions_recursive == 8

     print('''number of inversions = ''',					_lowerCAmelCase      )

     # testing an array with zero inversion (a sorted arr_1)

     arr_a.sort()
     _UpperCamelCase				    =       count_inversions_bf(_lowerCAmelCase      )
     _UpperCamelCase				    =       count_inversions_recursive(_lowerCAmelCase      )

     assert num_inversions_bf == num_inversions_recursive == 0
     print('''number of inversions = ''',					_lowerCAmelCase      )

     # an empty list should also have zero inversions
     _UpperCamelCase				    =       []
     _UpperCamelCase				    =       count_inversions_bf(_lowerCAmelCase      )
     _UpperCamelCase				    =       count_inversions_recursive(_lowerCAmelCase      )

     assert num_inversions_bf == num_inversions_recursive == 0
     print('''number of inversions = ''',					_lowerCAmelCase      )


if __name__ == "__main__":
   main()










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


__lowerCamelCase       :     str   =     logging.get_logger(__name__)

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



class 					A__   (       __snake_case       ,   __snake_case			):
      _UpperCAmelCase	:Optional[int]						    =   'convnextv2'





      def __init__( self       ,							A_=3       ,							A_=4       ,							A_=4       ,							A_=None       ,							A_=None       ,							A_="gelu"       ,							A_=0.02       ,							A_=1e-12       ,							A_=0.0       ,							A_=224       ,							A_=None       ,							A_=None       ,							**A_       ,							):
       '''simple docstring'''




       super().__init__(**A_   )

       UpperCamelCase	:					Dict       	=   num_channels
       UpperCamelCase	:					Union[str, Any]       	=   patch_size
       UpperCamelCase	:					Union[str, Any]       	=   num_stages
       UpperCamelCase	:					List[Any]       	=   [96, 192, 384, 768] 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	,    UpperCamelCase	:					str       	=   get_aligned_output_features_output_indices(
           out_features=A_       ,							out_indices=A_       ,							stage_names=self.stage_names   )
