


import argparse
import struct
import unittest







class lowerCAmelCase_		:

 '''simple docstring'''

 def __init__(			self	,   _UpperCAmelCase      ):
       snake_case_ =   data

       # Initialize hash values
       snake_case_ =   [
           0x6A09E667,
           0xBB67AE85,
           0x3C6EF372,
           0xA54FF53A,
           0x510E527F,
           0x9B05688C,
           0x1F83D9AB,
           0x5BE0CD19,
       ]

       # Initialize round constants
       snake_case_ =   [
           0x428A2F98,
           0x71374491,
           0xB5C0FBCF,
           0xE9B5DBA5,
           0x3956C25B,
           0x59F111F1,
           0x923F82A4,
           0xAB1C5ED5,
           0xD807AA98,
           0x12835B01,
           0x243185BE,
           0x550C7DC3,
           0x72BE5D74,
           0x80DEB1FE,
           0x9BDC06A7,
           0xC19BF174,
           0xE49B69C1,
           0xEFBE4786,
           0x0FC19DC6,
           0x240CA1CC,
           0x2DE92C6F,
           0x4A7484AA,
           0x5CB0A9DC,
           0x76F988DA,
           0x983E5152,
           0xA831C66D,
           0xB00327C8,
           0xBF597FC7,
           0xC6E00BF3,
           0xD5A79147,
           0x06CA6351,
           0x14292967,
           0x27B70A85,
           0x2E1B2138,
           0x4D2C6DFC,
           0x53380D13,
           0x650A7354,
           0x766A0ABB,
           0x81C2C92E,
           0x92722C85,
           0xA2BFE8A1,
           0xA81A664B,
           0xC24B8B70,
           0xC76C51A3,
           0xD192E819,
           0xD6990624,
           0xF40E3585,
           0x106AA070,
           0x19A4C116,
           0x1E376C08,
           0x2748774C,
           0x34B0BCB5,
           0x391C0CB3,
           0x4ED8AA4A,
           0x5B9CCA4F,
           0x682E6FF3,
           0x748F82EE,
           0x78A5636F,
           0x84C87814,
           0x8CC70208,
           0x90BEFFFA,
           0xA4506CEB,
           0xBEF9A3F7,
           0xC67178F2,
       ]

       snake_case_ =   self.preprocessing(self.data      )
       self.final_hash()



 @staticmethod
 def 		UpperCamelCase__  (			_UpperCAmelCase      ):
       snake_case_ =   b'''\x80''' + (b'''\x00''' * (63 - (len(_UpperCAmelCase      ) + 8) % 64))
       snake_case_ =   struct.pack('''>Q'''	,   (len(_UpperCAmelCase      ) * 8)      )
       return data + padding + big_endian_integer



 def 		UpperCamelCase__  (			self      ):
       # Convert into blocks of 64 bytes
       snake_case_ =   [
           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
             snake_case_ =   list(struct.unpack('''>16L'''	,   _UpperCAmelCase      )      )
             # add 48 0-ed integers
             words += [0] * 48

             snake_case_ ,					snake_case_ ,					snake_case_ ,					snake_case_ ,					snake_case_ ,					snake_case_ ,					snake_case_ ,					snake_case_ =   self.hashes

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

                         snake_case_ =   (
                             words[index - 16] + sa + words[index - 7] + sa
                         ) % 0x100000000

                   # Compression
                   snake_case_ =   self.ror(_UpperCAmelCase	,   6      ) ^ self.ror(_UpperCAmelCase	,   11      ) ^ self.ror(_UpperCAmelCase	,   25      )
                   snake_case_ =   (e & f) ^ ((~e & 0xFFFFFFFF) & g)
                   snake_case_ =   (
                       h + sa + ch + self.round_constants[index] + words[index]
                   ) % 0x100000000
                   snake_case_ =   self.ror(_UpperCAmelCase	,   2      ) ^ self.ror(_UpperCAmelCase	,   13      ) ^ self.ror(_UpperCAmelCase	,   22      )
                   snake_case_ =   (a & b) ^ (a & c) ^ (b & c)
                   snake_case_ =   (sa + maj) % 0x100000000

                   snake_case_ ,					snake_case_ ,					snake_case_ ,					snake_case_ ,					snake_case_ ,					snake_case_ ,					snake_case_ ,					snake_case_ =   (
                       g,
                       f,
                       e,
                       ((d + tempa) % 0x100000000),
                       c,
                       b,
                       a,
                       ((tempa + tempa) % 0x100000000),
                   )

             snake_case_ =   [a, b, c, d, e, f, g, h]

             # Modify final values
             snake_case_ =   [
                 ((element + mutated_hash_values[index]) % 0x100000000)
                 for index, element in enumerate(self.hashes      )
             ]

       snake_case_ =   ''''''.join([hex(_UpperCAmelCase      )[2:].zfill(8      ) for value in self.hashes]      )





 def 		UpperCamelCase__  (			self	,   _UpperCAmelCase	,   _UpperCAmelCase      ):
       return 0xFFFFFFFF & (value << (32 - rotations)) | (value >> rotations)







class lowerCAmelCase_		(				unittest.TestCase ):

 '''simple docstring'''

 def 		UpperCamelCase__  (			self      ):
       import hashlib

       snake_case_ =   bytes('''Test String'''	,   '''utf-8'''      )
       self.assertEqual(SHAaaa(_UpperCAmelCase      ).hash	,   hashlib.shaaaa(_UpperCAmelCase      ).hexdigest()      )






def  __lowerCAmelCase					()->						None:




      """simple docstring"""

      import doctest

      doctest.testmod()

      snake_case_ =   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'''      )

      snake_case_ =   parser.parse_args()

      snake_case_ =   args.input_string

      # hash input should be a bytestring
      if args.input_file:
            with open(args.input_file      ,      '''rb'''      ) as f:
                  snake_case_ =   f.read()
      else:
            snake_case_ =   bytes(SCREAMING_SNAKE_CASE      ,      '''utf-8'''      )

      print(SHAaaa(SCREAMING_SNAKE_CASE      ).hash      )


if __name__ == "__main__":
   main()



from typing import List, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCAmelCase    =					logging.get_logger(__name__)

UpperCAmelCase    =					{
    """huggingface/informer-tourism-monthly""": (
        """https://huggingface.co/huggingface/informer-tourism-monthly/resolve/main/config.json"""
    ),
    # See all Informer models at https://huggingface.co/models?filter=informer
}







class lowerCAmelCase_		(				lowerCamelCase__ ):

 '''simple docstring'''

 __snake_case				=						"informer"
 __snake_case				=						{
     "hidden_size": "d_model",
     "num_attention_heads": "encoder_attention_heads",
     "num_hidden_layers": "encoder_layers",
 }



 def __init__(			self	,   _UpperCAmelCase = None	,   _UpperCAmelCase = None	,   _UpperCAmelCase = "student_t"	,   _UpperCAmelCase = "nll"	,   _UpperCAmelCase = 1	,   _UpperCAmelCase = None	,   _UpperCAmelCase = "mean"	,   _UpperCAmelCase = 0	,   _UpperCAmelCase = 0	,   _UpperCAmelCase = 0	,   _UpperCAmelCase = 0	,   _UpperCAmelCase = None	,   _UpperCAmelCase = None	,   _UpperCAmelCase = 64	,   _UpperCAmelCase = 32	,   _UpperCAmelCase = 32	,   _UpperCAmelCase = 2	,   _UpperCAmelCase = 2	,   _UpperCAmelCase = 2	,   _UpperCAmelCase = 2	,   _UpperCAmelCase = True	,   _UpperCAmelCase = "gelu"	,   _UpperCAmelCase = 0.05	,   _UpperCAmelCase = 0.1	,   _UpperCAmelCase = 0.1	,   _UpperCAmelCase = 0.1	,   _UpperCAmelCase = 0.1	,   _UpperCAmelCase = 1_00	,   _UpperCAmelCase = 0.02	,   _UpperCAmelCase=True	,   _UpperCAmelCase = "prob"	,   _UpperCAmelCase = 5	,   _UpperCAmelCase = True	,   **_UpperCAmelCase	,   ):
       # time series specific configuration
       snake_case_ =   prediction_length
       snake_case_ =   context_length or prediction_length
       snake_case_ =   distribution_output
       snake_case_ =   loss
       snake_case_ =   input_size
       snake_case_ =   num_time_features
       snake_case_ =   lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
       snake_case_ =   scaling
       snake_case_ =   num_dynamic_real_features
       snake_case_ =   num_static_real_features
       snake_case_ =   num_static_categorical_features

       # set cardinality
       if cardinality and num_static_categorical_features > 0:
             if len(_UpperCAmelCase      ) != num_static_categorical_features:
                   raise ValueError(
                       '''The cardinality should be a list of the same length as `num_static_categorical_features`'''      )
             snake_case_ =   cardinality
       else:
             snake_case_ =   [0]

       # set embedding_dimension
       if embedding_dimension and num_static_categorical_features > 0:
             if len(_UpperCAmelCase      ) != num_static_categorical_features:
                   raise ValueError(
                       '''The embedding dimension should be a list of the same length as `num_static_categorical_features`'''      )
             snake_case_ =   embedding_dimension
       else:
             snake_case_ =   [min(50	,   (cat + 1) // 2      ) for cat in self.cardinality]

       snake_case_ =   num_parallel_samples

       # Transformer architecture configuration
       snake_case_ =   input_size * len(self.lags_sequence      ) + self._number_of_features
       snake_case_ =   d_model
       snake_case_ =   encoder_attention_heads
       snake_case_ =   decoder_attention_heads
       snake_case_ =   encoder_ffn_dim
       snake_case_ =   decoder_ffn_dim
       snake_case_ =   encoder_layers
       snake_case_ =   decoder_layers

       snake_case_ =   dropout
       snake_case_ =   attention_dropout
       snake_case_ =   activation_dropout
       snake_case_ =   encoder_layerdrop
       snake_case_ =   decoder_layerdrop

       snake_case_ =   activation_function
       snake_case_ =   init_std

       snake_case_ =   use_cache

       # Informer
       snake_case_ =   attention_type
       snake_case_ =   sampling_factor
       snake_case_ =   distil

       super().__init__(is_encoder_decoder=_UpperCAmelCase	,   **_UpperCAmelCase      )





 @property
 def 		UpperCamelCase__  (			self      ):
       return (
           sum(self.embedding_dimension      )
           + self.num_dynamic_real_features
           + self.num_time_features
           + self.num_static_real_features
           + self.input_size * 2  # the log1p(abs(loc)) and log(scale) features
       )