



import argparse
import struct
import unittest
class 			_lowerCAmelCase   :






			"""simple docstring"""





			def __init__(				self	:       str			,     lowercase	:       bytes   )						->					None:
									"""simple docstring"""







									__lowercase					=				data

									# Initialize hash values
									__lowercase					=				[
									    0X6a09_e667,
									    0Xbb67_ae85,
									    0X3c6e_f372,
									    0Xa54f_f53a,
									    0X510e_527f,
									    0X9b05_688c,
									    0X1f83_d9ab,
									    0X5be0_cd19,
									]

									# Initialize round constants
									__lowercase					=				[
									    0X428a_2f98,
									    0X7137_4491,
									    0Xb5c0_fbcf,
									    0Xe9b5_dba5,
									    0X3956_c25b,
									    0X59f1_11f1,
									    0X923f_82a4,
									    0Xab1c_5ed5,
									    0Xd807_aa98,
									    0X1283_5b01,
									    0X2431_85be,
									    0X550c_7dc3,
									    0X72be_5d74,
									    0X80de_b1fe,
									    0X9bdc_06a7,
									    0Xc19b_f174,
									    0Xe49b_69c1,
									    0Xefbe_4786,
									    0X0fc1_9dc6,
									    0X240c_a1cc,
									    0X2de9_2c6f,
									    0X4a74_84aa,
									    0X5cb0_a9dc,
									    0X76f9_88da,
									    0X983e_5152,
									    0Xa831_c66d,
									    0Xb003_27c8,
									    0Xbf59_7fc7,
									    0Xc6e0_0bf3,
									    0Xd5a7_9147,
									    0X06ca_6351,
									    0X1429_2967,
									    0X27b7_0a85,
									    0X2e1b_2138,
									    0X4d2c_6dfc,
									    0X5338_0d13,
									    0X650a_7354,
									    0X766a_0abb,
									    0X81c2_c92e,
									    0X9272_2c85,
									    0Xa2bf_e8a1,
									    0Xa81a_664b,
									    0Xc24b_8b70,
									    0Xc76c_51a3,
									    0Xd192_e819,
									    0Xd699_0624,
									    0Xf40e_3585,
									    0X106a_a070,
									    0X19a4_c116,
									    0X1e37_6c08,
									    0X2748_774c,
									    0X34b0_bcb5,
									    0X391c_0cb3,
									    0X4ed8_aa4a,
									    0X5b9c_ca4f,
									    0X682e_6ff3,
									    0X748f_82ee,
									    0X78a5_636f,
									    0X84c8_7814,
									    0X8cc7_0208,
									    0X90be_fffa,
									    0Xa450_6ceb,
									    0Xbef9_a3f7,
									    0Xc671_78f2,
									]

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





			@staticmethod
			def 		snake_case__			(				lowercase	:       bytes   )						->					bytes:
									"""simple docstring"""







									__lowercase					=				b"""\x80""" + (b"""\x00""" * (63 - (len(lowercase   ) + 8) % 64))
									__lowercase					=				struct.pack(""">Q"""			,     (len(lowercase   ) * 8)   )
									return data + padding + big_endian_integer





			def 		snake_case__			(				self	:       Tuple   )						->					None:
									"""simple docstring"""







									__lowercase					=				[
									    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
															__lowercase					=				list(struct.unpack(""">16L"""			,     lowercase   )   )
															# add 48 0-ed integers
															words += [0] * 48

															__lowercase	,			__lowercase	,			__lowercase	,			__lowercase	,			__lowercase	,			__lowercase	,			__lowercase	,			__lowercase					=				self.hashes

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

																											__lowercase					=				(
																											    words[index - 16] + sa + words[index - 7] + sa
																											) % 0X1_0000_0000

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

																					__lowercase	,			__lowercase	,			__lowercase	,			__lowercase	,			__lowercase	,			__lowercase	,			__lowercase	,			__lowercase					=				(
																					    g,
																					    f,
																					    e,
																					    ((d + tempa) % 0X1_0000_0000),
																					    c,
																					    b,
																					    a,
																					    ((tempa + tempa) % 0X1_0000_0000),
																					)

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

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

									__lowercase					=				"""""".join([hex(lowercase   )[2:].zfill(8   ) for value in self.hashes]   )







			def 		snake_case__			(				self	:       Union[str, Any]			,     lowercase	:       int			,     lowercase	:       int   )						->					int:
									"""simple docstring"""







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





class 			_lowerCAmelCase   ( unittest.TestCase			):






			"""simple docstring"""





			def 		snake_case__			(				self	:       Dict   )						->					None:
									"""simple docstring"""







									import hashlib

									__lowercase					=				bytes("""Test String"""			,     """utf-8"""   )
									self.assertEqual(SHAaaa(lowercase   ).hash			,     hashlib.shaaaa(lowercase   ).hexdigest()   )






def  UpperCAmelCase__    (    ) ->      None:
						import doctest

						doctest.testmod()

						__lowercase					=				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"""   )

						__lowercase					=				parser.parse_args()

						__lowercase					=				args.input_string

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

						print(SHAaaa(lowercase__   ).hash   )


if __name__ == "__main__":
			main()










from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


UpperCamelCase__ =						logging.get_logger(__name__)

UpperCamelCase__ =						{
    "hustvl/yolos-small": "https://huggingface.co/hustvl/yolos-small/resolve/main/config.json",
    # See all YOLOS models at https://huggingface.co/models?filter=yolos
}
class 			_lowerCAmelCase   ( _UpperCAmelCase			):






			"""simple docstring"""





			lowercase__      :  Union[str, Any]      =			"""yolos"""





			def __init__(				self	:       Optional[int]			,     lowercase	:       Any=768			,     lowercase	:       Tuple=12			,     lowercase	:       Tuple=12			,     lowercase	:       str=3_072			,     lowercase	:       Optional[Any]="gelu"			,     lowercase	:       Union[str, Any]=0.0			,     lowercase	:       Dict=0.0			,     lowercase	:       Optional[int]=0.02			,     lowercase	:       Optional[Any]=1E-1_2			,     lowercase	:       Tuple=[512, 864]			,     lowercase	:       Optional[int]=16			,     lowercase	:       Dict=3			,     lowercase	:       Optional[Any]=True			,     lowercase	:       Optional[int]=100			,     lowercase	:       Optional[int]=True			,     lowercase	:       Any=False			,     lowercase	:       Any=1			,     lowercase	:       Any=5			,     lowercase	:       List[str]=2			,     lowercase	:       Union[str, Any]=5			,     lowercase	:       str=2			,     lowercase	:       Tuple=0.1			,     **lowercase	:       str			,     )						->					Optional[Any]:
									"""simple docstring"""







									super().__init__(**lowercase   )

									__lowercase					=				hidden_size
									__lowercase					=				num_hidden_layers
									__lowercase					=				num_attention_heads
									__lowercase					=				intermediate_size
									__lowercase					=				hidden_act
									__lowercase					=				hidden_dropout_prob
									__lowercase					=				attention_probs_dropout_prob
									__lowercase					=				initializer_range
									__lowercase					=				layer_norm_eps
									__lowercase					=				image_size
									__lowercase					=				patch_size
									__lowercase					=				num_channels
									__lowercase					=				qkv_bias
									__lowercase					=				num_detection_tokens
									__lowercase					=				use_mid_position_embeddings
									__lowercase					=				auxiliary_loss
									# Hungarian matcher
									__lowercase					=				class_cost
									__lowercase					=				bbox_cost
									__lowercase					=				giou_cost
									# Loss coefficients
									__lowercase					=				bbox_loss_coefficient
									__lowercase					=				giou_loss_coefficient
									__lowercase					=				eos_coefficient





class 			_lowerCAmelCase   ( _UpperCAmelCase			):






			"""simple docstring"""





			lowercase__      :  Dict      =			version.parse("""1.11"""			)





			@property
			def 		snake_case__			(				self	:       List[str]   )						->					Mapping[str, Mapping[int, str]]:
									"""simple docstring"""







									return OrderedDict(
									    [
									        ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
									    ]   )





			@property
			def 		snake_case__			(				self	:       int   )						->					float:
									"""simple docstring"""







									return 1E-4







			@property
			def 		snake_case__			(				self	:       Optional[Any]   )						->					int:
									"""simple docstring"""







									return 12





