from collections.abc import Generator
from math import sin







def 			A__      (	snake_case_ :		bytes      ):
 if len(snake_case_      ) != 32:
  raise ValueError('''Input must be of length 32'''      )

 SCREAMING_SNAKE_CASE__:   Any=      b''''''
 for i in [3, 2, 1, 0]:
  little_endian += string_aa[8 * i : 8 * i + 8]
 return little_endian







def 			A__      (	snake_case_ :		int      ):
 if i < 0:
  raise ValueError('''Input must be non-negative'''      )

 SCREAMING_SNAKE_CASE__:   List[Any]=      format(snake_case_       ,				'''08x'''      )[-8:]
 SCREAMING_SNAKE_CASE__:   Optional[Any]=      b''''''
 for i in [3, 2, 1, 0]:
  little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode('''utf-8'''      )
 return little_endian_hex







def 			A__      (	snake_case_ :		bytes      ):
 SCREAMING_SNAKE_CASE__:   Union[str, Any]=      b''''''
 for char in message:
  bit_string += format(snake_case_       ,				'''08b'''      ).encode('''utf-8'''      )
 SCREAMING_SNAKE_CASE__:   List[str]=      format(len(snake_case_      )       ,				'''064b'''      ).encode('''utf-8'''      )

 # Pad bit_string to a multiple of 512 chars
 bit_string += b"1"
 while len(snake_case_      ) % 512 != 448:
  bit_string += b"0"
 bit_string += to_little_endian(start_len[32:]      ) + to_little_endian(start_len[:32]      )

 return bit_string







def 			A__      (	snake_case_ :		bytes      ):
 if len(snake_case_      ) % 512 != 0:
  raise ValueError('''Input must have length that\'s a multiple of 512'''      )

 for pos in range(0       ,				len(snake_case_      )       ,				512      ):
  SCREAMING_SNAKE_CASE__:   Tuple=      bit_string[pos : pos + 512]
  SCREAMING_SNAKE_CASE__:   List[str]=      []
  for i in range(0       ,				512       ,				32      ):
   block_words.append(int(to_little_endian(block[i : i + 32]      )       ,				2      )      )
  yield block_words







def 			A__      (	snake_case_ :		int      ):
 if i < 0:
  raise ValueError('''Input must be non-negative'''      )

 SCREAMING_SNAKE_CASE__:   str=      format(snake_case_       ,				'''032b'''      )
 SCREAMING_SNAKE_CASE__:   int=      ''''''
 for c in i_str:
  new_str += "1" if c == "0" else "0"
 return int(snake_case_       ,				2      )







def 			A__      (	snake_case_ :		int       ,				snake_case_ :		int      ):
 return (a + b) % 2**32







def 			A__      (	snake_case_ :		int       ,				snake_case_ :		int      ):
 if i < 0:
  raise ValueError('''Input must be non-negative'''      )
 if shift < 0:
  raise ValueError('''Shift must be non-negative'''      )
 return ((i << shift) ^ (i >> (32 - shift))) % 2**32







def 			A__      (	snake_case_ :		bytes      ):
 SCREAMING_SNAKE_CASE__:   List[str]=      preprocess(snake_case_      )

 SCREAMING_SNAKE_CASE__:   int=      [int(2**32 * abs(sin(i + 1      )      )      ) for i in range(64      )]

 # Starting states
 SCREAMING_SNAKE_CASE__:   Tuple=      0x67452301
 SCREAMING_SNAKE_CASE__:   Union[str, Any]=      0xefcdab89
 SCREAMING_SNAKE_CASE__:   List[Any]=      0x98badcfe
 SCREAMING_SNAKE_CASE__:   str=      0x10325476

 SCREAMING_SNAKE_CASE__:   Tuple=      [
     7,
     12,
     17,
     22,
     7,
     12,
     17,
     22,
     7,
     12,
     17,
     22,
     7,
     12,
     17,
     22,
     5,
     9,
     14,
     20,
     5,
     9,
     14,
     20,
     5,
     9,
     14,
     20,
     5,
     9,
     14,
     20,
     4,
     11,
     16,
     23,
     4,
     11,
     16,
     23,
     4,
     11,
     16,
     23,
     4,
     11,
     16,
     23,
     6,
     10,
     15,
     21,
     6,
     10,
     15,
     21,
     6,
     10,
     15,
     21,
     6,
     10,
     15,
     21,
 ]

 # Process bit string in chunks, each with 16 32-char words
 for block_words in get_block_words(snake_case_      ):
  SCREAMING_SNAKE_CASE__:   str=      aa
  SCREAMING_SNAKE_CASE__:   Optional[Any]=      ba
  SCREAMING_SNAKE_CASE__:   Tuple=      ca
  SCREAMING_SNAKE_CASE__:   Tuple=      da

  # Hash current chunk
  for i in range(64      ):
   if i <= 15:
    # f = (b & c) | (not_32(b) & d)     # Alternate definition for f
    SCREAMING_SNAKE_CASE__:   Union[str, Any]=      d ^ (b & (c ^ d))
    SCREAMING_SNAKE_CASE__:   int=      i
   elif i <= 31:
    # f = (d & b) | (not_32(d) & c)     # Alternate definition for f
    SCREAMING_SNAKE_CASE__:   str=      c ^ (d & (b ^ c))
    SCREAMING_SNAKE_CASE__:   List[Any]=      (5 * i + 1) % 16
   elif i <= 47:
    SCREAMING_SNAKE_CASE__:   Union[str, Any]=      b ^ c ^ d
    SCREAMING_SNAKE_CASE__:   List[Any]=      (3 * i + 5) % 16
   else:
    SCREAMING_SNAKE_CASE__:   Dict=      c ^ (b | not_aa(snake_case_      ))
    SCREAMING_SNAKE_CASE__:   Dict=      (7 * i) % 16
   SCREAMING_SNAKE_CASE__:   Any=      (f + a + added_consts[i] + block_words[g]) % 2**32
   SCREAMING_SNAKE_CASE__:   Tuple=      d
   SCREAMING_SNAKE_CASE__:   Union[str, Any]=      c
   SCREAMING_SNAKE_CASE__:   Dict=      b
   SCREAMING_SNAKE_CASE__:   Union[str, Any]=      sum_aa(snake_case_       ,				left_rotate_aa(snake_case_       ,				shift_amounts[i]      )      )

  # Add hashed chunk to running total
  SCREAMING_SNAKE_CASE__:   List[str]=      sum_aa(snake_case_       ,				snake_case_      )
  SCREAMING_SNAKE_CASE__:   Union[str, Any]=      sum_aa(snake_case_       ,				snake_case_      )
  SCREAMING_SNAKE_CASE__:   Optional[Any]=      sum_aa(snake_case_       ,				snake_case_      )
  SCREAMING_SNAKE_CASE__:   Any=      sum_aa(snake_case_       ,				snake_case_      )

 SCREAMING_SNAKE_CASE__:   Optional[int]=      reformat_hex(snake_case_      ) + reformat_hex(snake_case_      ) + reformat_hex(snake_case_      ) + reformat_hex(snake_case_      )
 return digest


if __name__ == "__main__":
      import doctest

      doctest.testmod()


import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible






class 		_lowerCamelCase		(   unittest.TestCase    ):
    def 						UpperCamelCase_				(  self   )       ->					str:
     SCREAMING_SNAKE_CASE__:   List[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''',
         '''text_encoder/model.safetensors''',
         '''unet/diffusion_pytorch_model.bin''',
         '''unet/diffusion_pytorch_model.safetensors''',
     ]
     self.assertTrue(is_safetensors_compatible(lowerCAmelCase   )   )
    def 						UpperCamelCase_				(  self   )       ->					int:
     SCREAMING_SNAKE_CASE__:   List[str]=      [
         '''unet/diffusion_pytorch_model.bin''',
         '''unet/diffusion_pytorch_model.safetensors''',
     ]
     self.assertTrue(is_safetensors_compatible(lowerCAmelCase   )   )
    def 						UpperCamelCase_				(  self   )       ->					Tuple:
     SCREAMING_SNAKE_CASE__:   Optional[int]=      [
         '''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(lowerCAmelCase   )   )
    def 						UpperCamelCase_				(  self   )       ->					Dict:
     SCREAMING_SNAKE_CASE__:   str=      [
         '''text_encoder/pytorch_model.bin''',
         '''text_encoder/model.safetensors''',
     ]
     self.assertTrue(is_safetensors_compatible(lowerCAmelCase   )   )
    def 						UpperCamelCase_				(  self   )       ->					str:
     SCREAMING_SNAKE_CASE__:   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''',
         # Removed: 'text_encoder/model.safetensors',
         '''unet/diffusion_pytorch_model.bin''',
         '''unet/diffusion_pytorch_model.safetensors''',
     ]
     self.assertFalse(is_safetensors_compatible(lowerCAmelCase   )   )
    def 						UpperCamelCase_				(  self   )       ->					List[str]:
     SCREAMING_SNAKE_CASE__:   Optional[int]=      [
         '''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''',
     ]
     SCREAMING_SNAKE_CASE__:   Any=      '''fp16'''
     self.assertTrue(is_safetensors_compatible(lowerCAmelCase , variant=lowerCAmelCase   )   )
    def 						UpperCamelCase_				(  self   )       ->					Any:
     SCREAMING_SNAKE_CASE__:   List[str]=      [
         '''unet/diffusion_pytorch_model.fp16.bin''',
         '''unet/diffusion_pytorch_model.fp16.safetensors''',
     ]
     SCREAMING_SNAKE_CASE__:   Dict=      '''fp16'''
     self.assertTrue(is_safetensors_compatible(lowerCAmelCase , variant=lowerCAmelCase   )   )
    def 						UpperCamelCase_				(  self   )       ->					Dict:
     # pass variant but use the non-variant filenames
     SCREAMING_SNAKE_CASE__:   List[str]=      [
         '''unet/diffusion_pytorch_model.bin''',
         '''unet/diffusion_pytorch_model.safetensors''',
     ]
     SCREAMING_SNAKE_CASE__:   Union[str, Any]=      '''fp16'''
     self.assertTrue(is_safetensors_compatible(lowerCAmelCase , variant=lowerCAmelCase   )   )
    def 						UpperCamelCase_				(  self   )       ->					List[Any]:
     SCREAMING_SNAKE_CASE__:   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',
     ]
     SCREAMING_SNAKE_CASE__:   List[Any]=      '''fp16'''
     self.assertFalse(is_safetensors_compatible(lowerCAmelCase , variant=lowerCAmelCase   )   )
    def 						UpperCamelCase_				(  self   )       ->					List[str]:
     SCREAMING_SNAKE_CASE__:   int=      [
         '''text_encoder/pytorch_model.fp16.bin''',
         '''text_encoder/model.fp16.safetensors''',
     ]
     SCREAMING_SNAKE_CASE__:   Any=      '''fp16'''
     self.assertTrue(is_safetensors_compatible(lowerCAmelCase , variant=lowerCAmelCase   )   )
    def 						UpperCamelCase_				(  self   )       ->					Optional[Any]:
     # pass variant but use the non-variant filenames
     SCREAMING_SNAKE_CASE__:   Optional[int]=      [
         '''text_encoder/pytorch_model.bin''',
         '''text_encoder/model.safetensors''',
     ]
     SCREAMING_SNAKE_CASE__:   str=      '''fp16'''
     self.assertTrue(is_safetensors_compatible(lowerCAmelCase , variant=lowerCAmelCase   )   )



    def 						UpperCamelCase_				(  self   )       ->					Union[str, Any]:
     SCREAMING_SNAKE_CASE__:   Tuple=      [
         '''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''',
     ]
     SCREAMING_SNAKE_CASE__:   str=      '''fp16'''
     self.assertFalse(is_safetensors_compatible(lowerCAmelCase , variant=lowerCAmelCase   )   )

