
'''simple docstring'''







import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible






class  lowerCAmelCase__   (  unittest.TestCase     ):






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     Tuple													=       [
											    'safety_checker/pytorch_model.bin',
											    'safety_checker/model.safetensors',
											    'vae/diffusion_pytorch_model.bin',
											    'vae/diffusion_pytorch_model.safetensors',
											    'text_encoder/pytorch_model.bin',
											    'text_encoder/model.safetensors',
											    'unet/diffusion_pytorch_model.bin',
											    'unet/diffusion_pytorch_model.safetensors',
											]
											self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_		)		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     Tuple													=       [
											    'unet/diffusion_pytorch_model.bin',
											    'unet/diffusion_pytorch_model.safetensors',
											]
											self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_		)		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     List[str]													=       [
											    'safety_checker/pytorch_model.bin',
											    'safety_checker/model.safetensors',
											    'vae/diffusion_pytorch_model.bin',
											    'vae/diffusion_pytorch_model.safetensors',
											    'text_encoder/pytorch_model.bin',
											    'text_encoder/model.safetensors',
											    'unet/diffusion_pytorch_model.bin',
											    # Removed: 'unet/diffusion_pytorch_model.safetensors',
											]
											self.assertFalse(is_safetensors_compatible(SCREAMING_SNAKE_CASE_		)		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     str													=       [
											    'text_encoder/pytorch_model.bin',
											    'text_encoder/model.safetensors',
											]
											self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_		)		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     Union[str, Any]													=       [
											    'safety_checker/pytorch_model.bin',
											    'safety_checker/model.safetensors',
											    'vae/diffusion_pytorch_model.bin',
											    'vae/diffusion_pytorch_model.safetensors',
											    'text_encoder/pytorch_model.bin',
											    # Removed: 'text_encoder/model.safetensors',
											    'unet/diffusion_pytorch_model.bin',
											    'unet/diffusion_pytorch_model.safetensors',
											]
											self.assertFalse(is_safetensors_compatible(SCREAMING_SNAKE_CASE_		)		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     Any													=       [
											    'safety_checker/pytorch_model.fp16.bin',
											    'safety_checker/model.fp16.safetensors',
											    'vae/diffusion_pytorch_model.fp16.bin',
											    'vae/diffusion_pytorch_model.fp16.safetensors',
											    'text_encoder/pytorch_model.fp16.bin',
											    'text_encoder/model.fp16.safetensors',
											    'unet/diffusion_pytorch_model.fp16.bin',
											    'unet/diffusion_pytorch_model.fp16.safetensors',
											]
											lowercase_	:     List[Any]													=       'fp16'
											self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_				,							variant=SCREAMING_SNAKE_CASE_		)		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     Any													=       [
											    'unet/diffusion_pytorch_model.fp16.bin',
											    'unet/diffusion_pytorch_model.fp16.safetensors',
											]
											lowercase_	:     Union[str, Any]													=       'fp16'
											self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_				,							variant=SCREAMING_SNAKE_CASE_		)		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     str													=       [
											    'unet/diffusion_pytorch_model.bin',
											    'unet/diffusion_pytorch_model.safetensors',
											]
											lowercase_	:     Optional[Any]													=       'fp16'
											self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_				,							variant=SCREAMING_SNAKE_CASE_		)		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     Dict													=       [
											    'safety_checker/pytorch_model.fp16.bin',
											    'safety_checker/model.fp16.safetensors',
											    'vae/diffusion_pytorch_model.fp16.bin',
											    'vae/diffusion_pytorch_model.fp16.safetensors',
											    'text_encoder/pytorch_model.fp16.bin',
											    'text_encoder/model.fp16.safetensors',
											    'unet/diffusion_pytorch_model.fp16.bin',
											    # Removed: 'unet/diffusion_pytorch_model.fp16.safetensors',
											]
											lowercase_	:     Optional[int]													=       'fp16'
											self.assertFalse(is_safetensors_compatible(SCREAMING_SNAKE_CASE_				,							variant=SCREAMING_SNAKE_CASE_		)		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     int													=       [
											    'text_encoder/pytorch_model.fp16.bin',
											    'text_encoder/model.fp16.safetensors',
											]
											lowercase_	:     Union[str, Any]													=       'fp16'
											self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_				,							variant=SCREAMING_SNAKE_CASE_		)		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     List[str]													=       [
											    'text_encoder/pytorch_model.bin',
											    'text_encoder/model.safetensors',
											]
											lowercase_	:     int													=       'fp16'
											self.assertTrue(is_safetensors_compatible(SCREAMING_SNAKE_CASE_				,							variant=SCREAMING_SNAKE_CASE_		)		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     List[Any]													=       [
											    'safety_checker/pytorch_model.fp16.bin',
											    'safety_checker/model.fp16.safetensors',
											    'vae/diffusion_pytorch_model.fp16.bin',
											    'vae/diffusion_pytorch_model.fp16.safetensors',
											    'text_encoder/pytorch_model.fp16.bin',
											    # 'text_encoder/model.fp16.safetensors',
											    'unet/diffusion_pytorch_model.fp16.bin',
											    'unet/diffusion_pytorch_model.fp16.safetensors',
											]
											lowercase_	:     str													=       'fp16'
											self.assertFalse(is_safetensors_compatible(SCREAMING_SNAKE_CASE_				,							variant=SCREAMING_SNAKE_CASE_		)		)







'''simple docstring'''



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				List[Any]							)     ->		str:
     __lowerCamelCase   :	Tuple								=		0
     __lowerCamelCase   :	Optional[int]								=		len(UpperCAmelCase_							)

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

     return num_inversions



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				str							)     ->		Optional[int]:
     if len(UpperCAmelCase_							) <= 1:
          return arr, 0
     __lowerCamelCase   :	str								=		len(UpperCAmelCase_							) // 2
     __lowerCamelCase   :	List[Any]								=		arr[0:mid]
     __lowerCamelCase   :	List[str]								=		arr[mid:]

     __lowerCamelCase				,       __lowerCamelCase   :	int								=		count_inversions_recursive(UpperCAmelCase_							)
     __lowerCamelCase				,       __lowerCamelCase   :	Optional[Any]								=		count_inversions_recursive(UpperCAmelCase_							)
     __lowerCamelCase				,       __lowerCamelCase   :	Any								=		_count_cross_inversions(UpperCAmelCase_      ,    UpperCAmelCase_							)

     __lowerCamelCase   :	Optional[int]								=		inversion_p + inversions_q + cross_inversions
     return c, num_inversions



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				List[Any]      ,    UpperCAmelCase_    :				List[str]							)     ->		Optional[Any]:
     __lowerCamelCase   :	List[str]								=		[]
     __lowerCamelCase   :	Optional[int]								=		0
     while i < len(UpperCAmelCase_							) and j < len(UpperCAmelCase_							):
          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(UpperCAmelCase_							) - i
               r.append(q[j]							)
               j += 1
          else:
               r.append(p[i]							)
               i += 1

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

     return r, num_inversion



def 			UpperCAmelCase__					(	)     ->		List[str]:
     __lowerCamelCase   :	Any								=		[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)

     __lowerCamelCase   :	Optional[Any]								=		count_inversions_bf(UpperCAmelCase_							)
     __lowerCamelCase				,       __lowerCamelCase   :	Dict								=		count_inversions_recursive(UpperCAmelCase_							)

     assert num_inversions_bf == num_inversions_recursive == 8

     print('number of inversions = '      ,    UpperCAmelCase_							)

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

     arr_a.sort()
     __lowerCamelCase   :	Optional[Any]								=		count_inversions_bf(UpperCAmelCase_							)
     __lowerCamelCase				,       __lowerCamelCase   :	int								=		count_inversions_recursive(UpperCAmelCase_							)

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

     # an empty list should also have zero inversions
     __lowerCamelCase   :	Dict								=		[]
     __lowerCamelCase   :	Optional[Any]								=		count_inversions_bf(UpperCAmelCase_							)
     __lowerCamelCase				,       __lowerCamelCase   :	Union[str, Any]								=		count_inversions_recursive(UpperCAmelCase_							)

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


if __name__ == "__main__":
      main()






