





import gc
import unittest

import torch
from parameterized import parameterized

from diffusers import AutoencoderKL
from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import enable_full_determinism

from .test_modeling_common import ModelTesterMixin, UNetTesterMixin


enable_full_determinism()


class        __magic_name__	(				lowerCamelCase__     ,					lowerCamelCase__     ,					unittest.TestCase				):





     """simple docstring"""



     __UpperCamelCase            =  AutoencoderKL
     __UpperCamelCase            =  '''sample'''
     __UpperCamelCase            =  1e-2



     @property
     def     SCREAMING_SNAKE_CASE		(				self							:Any	):





        '''simple docstring'''




        A_       :					List[Any]        =      4
        A_       :					List[Any]        =      3
        A_       :					List[str]        =      (32, 32)

        A_       :					int        =      floats_tensor((batch_size, num_channels) + sizes	).to(snake_case	)

        return {"sample": image}



     @property
     def     SCREAMING_SNAKE_CASE		(				self							:Union[str, Any]	):





        '''simple docstring'''




        return (3, 32, 32)



     @property
     def     SCREAMING_SNAKE_CASE		(				self							:Any	):





        '''simple docstring'''




        return (3, 32, 32)



     def     SCREAMING_SNAKE_CASE		(				self							:Union[str, Any]	):





        '''simple docstring'''




        A_       :					List[Any]        =      {
            "block_out_channels": [32, 64],
            "in_channels": 3,
            "out_channels": 3,
            "down_block_types": ["DownEncoderBlock2D", "DownEncoderBlock2D"],
            "up_block_types": ["UpDecoderBlock2D", "UpDecoderBlock2D"],
            "latent_channels": 4,
        }
        A_       :					Union[str, Any]        =      self.dummy_input
        return init_dict, inputs_dict



     def     SCREAMING_SNAKE_CASE		(				self							:Any	):





        '''simple docstring'''




        pass



     def     SCREAMING_SNAKE_CASE		(				self							:int	):





        '''simple docstring'''




        pass



     @unittest.skipIf(torch_device == "mps"      ,   "Gradient checkpointing skipped on MPS"	)
     def     SCREAMING_SNAKE_CASE		(				self							:Optional[int]	):





        '''simple docstring'''




        A_   ,    A_       :					Optional[int]        =      self.prepare_init_args_and_inputs_for_common()
        A_       :					List[str]        =      self.model_class(**snake_case	)
        model.to(snake_case	)

        assert not model.is_gradient_checkpointing and model.training

        A_       :					Any        =      model(**snake_case	).sample
        # run the backwards pass on the model. For backwards pass, for simplicity purpose,
        # we won't calculate the loss and rather backprop on out.sum()
        model.zero_grad()

        A_       :					Dict        =      torch.randn_like(snake_case	)
        A_       :					str        =      (out - labels).mean()
        loss.backward()

        # re-instantiate the model now enabling gradient checkpointing
        A_       :					str        =      self.model_class(**snake_case	)
        # clone model
        model_a.load_state_dict(model.state_dict()	)
        model_a.to(snake_case	)
        model_a.enable_gradient_checkpointing()

        assert model_a.is_gradient_checkpointing and model_a.training

        A_       :					Tuple        =      model_a(**snake_case	).sample
        # run the backwards pass on the model. For backwards pass, for simplicity purpose,
        # we won't calculate the loss and rather backprop on out.sum()
        model_a.zero_grad()
        A_       :					Union[str, Any]        =      (out_a - labels).mean()
        loss_a.backward()

        # compare the output and parameters gradients
        self.assertTrue((loss - loss_a).abs() < 1e-5	)
        A_       :					str        =      dict(model.named_parameters()	)
        A_       :					int        =      dict(model_a.named_parameters()	)
        for name, param in named_params.items():
           self.assertTrue(torch_all_close(param.grad.data      ,   named_params_a[name].grad.data      ,   atol=5e-5	)	)



     def     SCREAMING_SNAKE_CASE		(				self							:Union[str, Any]	):





        '''simple docstring'''




        A_   ,    A_       :					Optional[Any]        =      AutoencoderKL.from_pretrained("fusing/autoencoder-kl-dummy"      ,   output_loading_info=snake_case	)
        self.assertIsNotNone(snake_case	)
        self.assertEqual(len(loading_info["missing_keys"]	)      ,   0	)

        model.to(snake_case	)
        A_       :					Optional[int]        =      model(**self.dummy_input	)

        assert image is not None, "Make sure output is not None"





     def     SCREAMING_SNAKE_CASE		(				self							:Optional[int]	):





        '''simple docstring'''




        A_       :					int        =      AutoencoderKL.from_pretrained("fusing/autoencoder-kl-dummy"	)
        A_       :					Optional[Any]        =      model.to(snake_case	)
        model.eval()

        if torch_device == "mps":
           A_       :					Dict        =      torch.manual_seed(0	)
        else:
           A_       :					Dict        =      torch.Generator(device=snake_case	).manual_seed(0	)

        A_       :					int        =      torch.randn(
            1      ,   model.config.in_channels      ,   model.config.sample_size      ,   model.config.sample_size      ,   generator=torch.manual_seed(0	)      ,   )
        A_       :					Tuple        =      image.to(snake_case	)
        with torch.no_grad():
           A_       :					Tuple        =      model(snake_case      ,   sample_posterior=snake_case      ,   generator=snake_case	).sample

        A_       :					Dict        =      output[0, -1, -3:, -3:].flatten().cpu()

        # Since the VAE Gaussian prior's generator is seeded on the appropriate device,
        # the expected output slices are not the same for CPU and GPU.
        if torch_device == "mps":
           A_       :					Union[str, Any]        =      torch.tensor(
               [
                   -4.0078e-01,
                   -3.8323e-04,
                   -1.2681e-01,
                   -1.1462e-01,
                   2.0095e-01,
                   1.0893e-01,
                   -8.8247e-02,
                   -3.0361e-01,
                   -9.8644e-03,
               ]	)
        elif torch_device == "cpu":
           A_       :					int        =      torch.tensor(
               [-0.1352, 0.0878, 0.0419, -0.0818, -0.1069, 0.0688, -0.1458, -0.4446, -0.0026]	)
        else:
           A_       :					Any        =      torch.tensor(
               [-0.2421, 0.4642, 0.2507, -0.0438, 0.0682, 0.3160, -0.2018, -0.0727, 0.2485]	)

        self.assertTrue(torch_all_close(snake_case      ,   snake_case      ,   rtol=1e-2	)	)




@slow
class        __magic_name__	(				unittest.TestCase				):





     """simple docstring"""



     def     SCREAMING_SNAKE_CASE		(				self							:Any      ,   snake_case							:Dict      ,   snake_case							:Dict	):





        '''simple docstring'''




        return f"gaussian_noise_s={seed}_shape={'_'.join([str(snake_case	) for s in shape]	)}.npy"



     def     SCREAMING_SNAKE_CASE		(				self							:str	):





        '''simple docstring'''




        super().tearDown()
        gc.collect()
        torch.cuda.empty_cache()



     def     SCREAMING_SNAKE_CASE		(				self							:List[str]      ,   snake_case							:int=0      ,   snake_case							:List[str]=(4, 3, 512, 512)      ,   snake_case							:List[str]=False	):





        '''simple docstring'''




        A_       :					Union[str, Any]        =      torch.floataa if fpaa else torch.floataa
        A_       :					Dict        =      torch.from_numpy(load_hf_numpy(self.get_file_format(snake_case      ,   snake_case	)	)	).to(snake_case	).to(snake_case	)
        return image



     def     SCREAMING_SNAKE_CASE		(				self							:Optional[int]      ,   snake_case							:int="CompVis/stable-diffusion-v1-4"      ,   snake_case							:Tuple=False	):





        '''simple docstring'''




        A_       :					Dict        =      "fp16" if fpaa else None
        A_       :					Dict        =      torch.floataa if fpaa else torch.floataa

        A_       :					Tuple        =      AutoencoderKL.from_pretrained(
            snake_case      ,   subfolder="vae"      ,   torch_dtype=snake_case      ,   revision=snake_case      ,   )
        model.to(snake_case	).eval()

        return model



     def     SCREAMING_SNAKE_CASE		(				self							:str      ,   snake_case							:Optional[int]=0	):





        '''simple docstring'''




        if torch_device == "mps":
           return torch.manual_seed(snake_case	)
        return torch.Generator(device=snake_case	).manual_seed(snake_case	)



     @parameterized.expand(
         [
             # fmt: off
             [33, [-0.1603, 0.9878, -0.0495, -0.0790, -0.2709, 0.8375, -0.2060, -0.0824], [-0.2395, 0.0098, 0.0102, -0.0709, -0.2840, -0.0274, -0.0718, -0.1824]],
             [47, [-0.2376, 0.1168, 0.1332, -0.4840, -0.2508, -0.0791, -0.0493, -0.4089], [0.0350, 0.0847, 0.0467, 0.0344, -0.0842, -0.0547, -0.0633, -0.1131]],
             # fmt: on
         ]	)
     def     SCREAMING_SNAKE_CASE		(				self							:Optional[Any]      ,   snake_case							:Optional[int]      ,   snake_case							:str      ,   snake_case							:int	):





        '''simple docstring'''




        A_       :					Union[str, Any]        =      self.get_sd_vae_model()
        A_       :					Tuple        =      self.get_sd_image(snake_case	)
        A_       :					Union[str, Any]        =      self.get_generator(snake_case	)

        with torch.no_grad():
           A_       :					Optional[int]        =      model(snake_case      ,   generator=snake_case      ,   sample_posterior=snake_case	).sample

        assert sample.shape == image.shape

        A_       :					List[Any]        =      sample[-1, -2:, -2:, :2].flatten().float().cpu()
        A_       :					List[Any]        =      torch.tensor(expected_slice_mps if torch_device == "mps" else expected_slice	)

        assert torch_all_close(snake_case      ,   snake_case      ,   atol=3e-3	)



     @parameterized.expand(
         [
             # fmt: off
             [33, [-0.0513, 0.0289, 1.3799, 0.2166, -0.2573, -0.0871, 0.5103, -0.0999]],
             [47, [-0.4128, -0.1320, -0.3704, 0.1965, -0.4116, -0.2332, -0.3340, 0.2247]],
             # fmt: on
         ]	)
     @require_torch_gpu
     def     SCREAMING_SNAKE_CASE		(				self							:Any      ,   snake_case							:Optional[int]      ,   snake_case							:Any	):





        '''simple docstring'''




        A_       :					Dict        =      self.get_sd_vae_model(fpaa=snake_case	)
        A_       :					int        =      self.get_sd_image(snake_case      ,   fpaa=snake_case	)
        A_       :					List[Any]        =      self.get_generator(snake_case	)

        with torch.no_grad():
           A_       :					Any        =      model(snake_case      ,   generator=snake_case      ,   sample_posterior=snake_case	).sample

        assert sample.shape == image.shape

        A_       :					List[Any]        =      sample[-1, -2:, :2, -2:].flatten().float().cpu()
        A_       :					Any        =      torch.tensor(snake_case	)

        assert torch_all_close(snake_case      ,   snake_case      ,   atol=1e-2	)



     @parameterized.expand(
         [
             # fmt: off
             [33, [-0.1609, 0.9866, -0.0487, -0.0777, -0.2716, 0.8368, -0.2055, -0.0814], [-0.2395, 0.0098, 0.0102, -0.0709, -0.2840, -0.0274, -0.0718, -0.1824]],
             [47, [-0.2377, 0.1147, 0.1333, -0.4841, -0.2506, -0.0805, -0.0491, -0.4085], [0.0350, 0.0847, 0.0467, 0.0344, -0.0842, -0.0547, -0.0633, -0.1131]],
             # fmt: on
         ]	)
     def     SCREAMING_SNAKE_CASE		(				self							:int      ,   snake_case							:List[str]      ,   snake_case							:List[str]      ,   snake_case							:Any	):





        '''simple docstring'''




        A_       :					Optional[Any]        =      self.get_sd_vae_model()
        A_       :					List[Any]        =      self.get_sd_image(snake_case	)

        with torch.no_grad():
           A_       :					Optional[int]        =      model(snake_case	).sample

        assert sample.shape == image.shape

        A_       :					List[Any]        =      sample[-1, -2:, -2:, :2].flatten().float().cpu()
        A_       :					Dict        =      torch.tensor(expected_slice_mps if torch_device == "mps" else expected_slice	)

        assert torch_all_close(snake_case      ,   snake_case      ,   atol=3e-3	)



     @parameterized.expand(
         [
             # fmt: off
             [13, [-0.2051, -0.1803, -0.2311, -0.2114, -0.3292, -0.3574, -0.2953, -0.3323]],
             [37, [-0.2632, -0.2625, -0.2199, -0.2741, -0.4539, -0.4990, -0.3720, -0.4925]],
             # fmt: on
         ]	)
     @require_torch_gpu
     def     SCREAMING_SNAKE_CASE		(				self							:int      ,   snake_case							:str      ,   snake_case							:str	):





        '''simple docstring'''




        A_       :					Tuple        =      self.get_sd_vae_model()
        A_       :					int        =      self.get_sd_image(snake_case      ,   shape=(3, 4, 64, 64)	)

        with torch.no_grad():
           A_       :					Union[str, Any]        =      model.decode(snake_case	).sample

        assert list(sample.shape	) == [3, 3, 512, 512]

        A_       :					List[Any]        =      sample[-1, -2:, :2, -2:].flatten().cpu()
        A_       :					int        =      torch.tensor(snake_case	)

        assert torch_all_close(snake_case      ,   snake_case      ,   atol=1e-3	)



     @parameterized.expand(
         [
             # fmt: off
             [27, [-0.0369, 0.0207, -0.0776, -0.0682, -0.1747, -0.1930, -0.1465, -0.2039]],
             [16, [-0.1628, -0.2134, -0.2747, -0.2642, -0.3774, -0.4404, -0.3687, -0.4277]],
             # fmt: on
         ]	)
     @require_torch_gpu
     def     SCREAMING_SNAKE_CASE		(				self							:List[str]      ,   snake_case							:Optional[int]      ,   snake_case							:Any	):





        '''simple docstring'''




        A_       :					List[Any]        =      self.get_sd_vae_model(fpaa=snake_case	)
        A_       :					Tuple        =      self.get_sd_image(snake_case      ,   shape=(3, 4, 64, 64)      ,   fpaa=snake_case	)

        with torch.no_grad():
           A_       :					Any        =      model.decode(snake_case	).sample

        assert list(sample.shape	) == [3, 3, 512, 512]

        A_       :					Dict        =      sample[-1, -2:, :2, -2:].flatten().float().cpu()
        A_       :					Any        =      torch.tensor(snake_case	)

        assert torch_all_close(snake_case      ,   snake_case      ,   atol=5e-3	)



     @parameterized.expand([(13,), (16,), (27,)]	)
     @require_torch_gpu
     @unittest.skipIf(not is_xformers_available()      ,   reason="xformers is not required when using PyTorch 2.0."	)
     def     SCREAMING_SNAKE_CASE		(				self							:Union[str, Any]      ,   snake_case							:List[Any]	):





        '''simple docstring'''




        A_       :					List[str]        =      self.get_sd_vae_model(fpaa=snake_case	)
        A_       :					Union[str, Any]        =      self.get_sd_image(snake_case      ,   shape=(3, 4, 64, 64)      ,   fpaa=snake_case	)

        with torch.no_grad():
           A_       :					Dict        =      model.decode(snake_case	).sample

        model.enable_xformers_memory_efficient_attention()
        with torch.no_grad():
           A_       :					List[str]        =      model.decode(snake_case	).sample

        assert list(sample.shape	) == [3, 3, 512, 512]

        assert torch_all_close(snake_case      ,   snake_case      ,   atol=1e-1	)



     @parameterized.expand([(13,), (16,), (37,)]	)
     @require_torch_gpu
     @unittest.skipIf(not is_xformers_available()      ,   reason="xformers is not required when using PyTorch 2.0."	)
     def     SCREAMING_SNAKE_CASE		(				self							:str      ,   snake_case							:Optional[Any]	):





        '''simple docstring'''




        A_       :					Tuple        =      self.get_sd_vae_model()
        A_       :					str        =      self.get_sd_image(snake_case      ,   shape=(3, 4, 64, 64)	)

        with torch.no_grad():
           A_       :					List[Any]        =      model.decode(snake_case	).sample

        model.enable_xformers_memory_efficient_attention()
        with torch.no_grad():
           A_       :					Any        =      model.decode(snake_case	).sample

        assert list(sample.shape	) == [3, 3, 512, 512]

        assert torch_all_close(snake_case      ,   snake_case      ,   atol=1e-2	)





     @parameterized.expand(
         [
             # fmt: off
             [33, [-0.3001, 0.0918, -2.6984, -3.9720, -3.2099, -5.0353, 1.7338, -0.2065, 3.4267]],
             [47, [-1.5030, -4.3871, -6.0355, -9.1157, -1.6661, -2.7853, 2.1607, -5.0823, 2.5633]],
             # fmt: on
         ]	)
     def     SCREAMING_SNAKE_CASE		(				self							:Optional[int]      ,   snake_case							:Optional[int]      ,   snake_case							:Union[str, Any]	):





        '''simple docstring'''




        A_       :					int        =      self.get_sd_vae_model()
        A_       :					int        =      self.get_sd_image(snake_case	)
        A_       :					Tuple        =      self.get_generator(snake_case	)

        with torch.no_grad():
           A_       :					Optional[int]        =      model.encode(snake_case	).latent_dist
           A_       :					str        =      dist.sample(generator=snake_case	)

        assert list(sample.shape	) == [image.shape[0], 4] + [i // 8 for i in image.shape[2:]]

        A_       :					Union[str, Any]        =      sample[0, -1, -3:, -3:].flatten().cpu()
        A_       :					Union[str, Any]        =      torch.tensor(snake_case	)

        A_       :					Optional[int]        =      3e-3 if torch_device != "mps" else 1e-2
        assert torch_all_close(snake_case      ,   snake_case      ,   atol=snake_case	)







import argparse
import struct
import unittest


class        __magic_name__	:





     """simple docstring"""



     def __init__(				self							:str      ,   snake_case							:bytes	):





        '''simple docstring'''




        A_       :					Dict        =      data

        # Initialize hash values
        A_       :					Union[str, Any]        =      [
            0x6a_09_e6_67,
            0xbb_67_ae_85,
            0x3c_6e_f3_72,
            0xa5_4f_f5_3a,
            0x51_0e_52_7f,
            0x9b_05_68_8c,
            0x1f_83_d9_ab,
            0x5b_e0_cd_19,
        ]

        # Initialize round constants
        A_       :					List[Any]        =      [
            0x42_8a_2f_98,
            0x71_37_44_91,
            0xb5_c0_fb_cf,
            0xe9_b5_db_a5,
            0x39_56_c2_5b,
            0x59_f1_11_f1,
            0x92_3f_82_a4,
            0xab_1c_5e_d5,
            0xd8_07_aa_98,
            0x12_83_5b_01,
            0x24_31_85_be,
            0x55_0c_7d_c3,
            0x72_be_5d_74,
            0x80_de_b1_fe,
            0x9b_dc_06_a7,
            0xc1_9b_f1_74,
            0xe4_9b_69_c1,
            0xef_be_47_86,
            0x0f_c1_9d_c6,
            0x24_0c_a1_cc,
            0x2d_e9_2c_6f,
            0x4a_74_84_aa,
            0x5c_b0_a9_dc,
            0x76_f9_88_da,
            0x98_3e_51_52,
            0xa8_31_c6_6d,
            0xb0_03_27_c8,
            0xbf_59_7f_c7,
            0xc6_e0_0b_f3,
            0xd5_a7_91_47,
            0x06_ca_63_51,
            0x14_29_29_67,
            0x27_b7_0a_85,
            0x2e_1b_21_38,
            0x4d_2c_6d_fc,
            0x53_38_0d_13,
            0x65_0a_73_54,
            0x76_6a_0a_bb,
            0x81_c2_c9_2e,
            0x92_72_2c_85,
            0xa2_bf_e8_a1,
            0xa8_1a_66_4b,
            0xc2_4b_8b_70,
            0xc7_6c_51_a3,
            0xd1_92_e8_19,
            0xd6_99_06_24,
            0xf4_0e_35_85,
            0x10_6a_a0_70,
            0x19_a4_c1_16,
            0x1e_37_6c_08,
            0x27_48_77_4c,
            0x34_b0_bc_b5,
            0x39_1c_0c_b3,
            0x4e_d8_aa_4a,
            0x5b_9c_ca_4f,
            0x68_2e_6f_f3,
            0x74_8f_82_ee,
            0x78_a5_63_6f,
            0x84_c8_78_14,
            0x8c_c7_02_08,
            0x90_be_ff_fa,
            0xa4_50_6c_eb,
            0xbe_f9_a3_f7,
            0xc6_71_78_f2,
        ]

        A_       :					Any        =      self.preprocessing(self.data	)
        self.final_hash()



     @staticmethod
     def     SCREAMING_SNAKE_CASE		(				snake_case							:bytes	):





        '''simple docstring'''




        A_       :					List[Any]        =      B"\x80" + (B"\x00" * (63 - (len(snake_case	) + 8) % 64))
        A_       :					str        =      struct.pack(">Q"      ,   (len(snake_case	) * 8)	)
        return data + padding + big_endian_integer



     def     SCREAMING_SNAKE_CASE		(				self							:Any	):





        '''simple docstring'''




        A_       :					Tuple        =      [
            self.preprocessed_data[x : x + 64]
            for x in range(0      ,   len(self.preprocessed_data	)      ,   64	)
        ]

        for block in self.blocks:
           # Convert the given block into a list of 4 byte integers
           A_       :					Dict        =      list(struct.unpack(">16L"      ,   snake_case	)	)
           # add 48 0-ed integers
           words += [0] * 48

           A_   ,    A_   ,    A_   ,    A_   ,    A_   ,    A_   ,    A_   ,    A_       :					int        =      self.hashes

           for index in range(0      ,   64	):
              if index > 15:
                 # modify the zero-ed indexes at the end of the array
                 A_       :					int        =      (
                     self.ror(words[index - 15]      ,   7	)
                     ^ self.ror(words[index - 15]      ,   18	)
                     ^ (words[index - 15] >> 3)
                 )
                 A_       :					Any        =      (
                     self.ror(words[index - 2]      ,   17	)
                     ^ self.ror(words[index - 2]      ,   19	)
                     ^ (words[index - 2] >> 10)
                 )

                 A_       :					Optional[int]        =      (
                     words[index - 16] + sa + words[index - 7] + sa
                 ) % 0x1_00_00_00_00

              # Compression
              A_       :					Dict        =      self.ror(snake_case      ,   6	) ^ self.ror(snake_case      ,   11	) ^ self.ror(snake_case      ,   25	)
              A_       :					int        =      (e & f) ^ ((~e & 0xff_ff_ff_ff) & g)
              A_       :					Optional[Any]        =      (
                  h + sa + ch + self.round_constants[index] + words[index]
              ) % 0x1_00_00_00_00
              A_       :					List[str]        =      self.ror(snake_case      ,   2	) ^ self.ror(snake_case      ,   13	) ^ self.ror(snake_case      ,   22	)
              A_       :					List[Any]        =      (a & b) ^ (a & c) ^ (b & c)
              A_       :					Dict        =      (sa + maj) % 0x1_00_00_00_00

              A_   ,    A_   ,    A_   ,    A_   ,    A_   ,    A_   ,    A_   ,    A_       :					Optional[int]        =      (
                  g,
                  f,
                  e,
                  ((d + tempa) % 0x1_00_00_00_00),
                  c,
                  b,
                  a,
                  ((tempa + tempa) % 0x1_00_00_00_00),
              )

           A_       :					List[str]        =      [a, b, c, d, e, f, g, h]

           # Modify final values
           A_       :					List[str]        =      [
               ((element + mutated_hash_values[index]) % 0x1_00_00_00_00)
               for index, element in enumerate(self.hashes	)
           ]

        A_       :					Optional[int]        =      "".join([hex(snake_case	)[2:].zfill(8	) for value in self.hashes]	)





     def     SCREAMING_SNAKE_CASE		(				self							:Optional[Any]      ,   snake_case							:int      ,   snake_case							:int	):





        '''simple docstring'''




        return 0xff_ff_ff_ff & (value << (32 - rotations)) | (value >> rotations)




class        __magic_name__	(				unittest.TestCase				):





     """simple docstring"""



     def     SCREAMING_SNAKE_CASE		(				self							:List[Any]	):





        '''simple docstring'''




        import hashlib

        A_       :					int        =      bytes("Test String"      ,   "utf-8"	)
        self.assertEqual(SHAaaa(snake_case	).hash      ,   hashlib.shaaaa(snake_case	).hexdigest()	)




def   __snake_case    (       )			->    None:
   import doctest

   doctest.testmod()

   A_       :					Optional[Any]        =      argparse.ArgumentParser()
   parser.add_argument(
       "-s"					,					"--string"					,					dest="input_string"					,					default="Hello World!! Welcome to Cryptography"					,					help="Hash the string"					,					)
   parser.add_argument(
       "-f"					,					"--file"					,					dest="input_file"					,					help="Hash contents of a file"						)

   A_       :					List[Any]        =      parser.parse_args()

   A_       :					List[Any]        =      args.input_string

   # hash input should be a bytestring
   if args.input_file:
      with open(args.input_file					,					"rb"						) as f:
         A_       :					Optional[Any]        =      f.read()
   else:
      A_       :					Any        =      bytes(_lowerCAmelCase					,					"utf-8"						)

   print(SHAaaa(_lowerCAmelCase						).hash						)


if __name__ == "__main__":
 main()
