
'''simple docstring'''







import argparse
import hashlib  # hashlib is only used inside the Test class
import struct


class 						__UpperCAmelCase      :


							def __init__(       self    ,   lowerCAmelCase_  ):





								"""simple docstring"""






								_snake_case   						=		data
								_snake_case   						=		[0X6_7_4_5_2_3_0_1, 0XE_F_C_D_A_B_8_9, 0X9_8_B_A_D_C_F_E, 0X1_0_3_2_5_4_7_6, 0XC_3_D_2_E_1_F_0]


							@staticmethod
							def  lowerCamelCase				(       lowerCAmelCase_    ,   lowerCAmelCase_  ):





								"""simple docstring"""






								return ((n << b) | (n >> (32 - b))) & 0XF_F_F_F_F_F_F_F


							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






								_snake_case   						=		B'\x80' + B'\x00' * (63 - (len(self.data  ) + 8) % 64)
								_snake_case   						=		self.data + padding + struct.pack('>Q'    ,   8 * len(self.data  )  )
								return padded_data


							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






								return [
								    self.padded_data[i : i + 64] for i in range(0    ,   len(self.padded_data  )    ,   64  )
								]


							def  lowerCamelCase				(       self    ,   lowerCAmelCase_  ):





								"""simple docstring"""






								_snake_case   						=		list(struct.unpack('>16L'    ,   lowerCAmelCase_  )  ) + [0] * 64
								for i in range(16    ,   80  ):
									_snake_case   						=		self.rotate((w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16])    ,   1  )
								return w




							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






								_snake_case   						=		self.padding()
								_snake_case   						=		self.split_blocks()
								for block in self.blocks:
									_snake_case   						=		self.expand_block(lowerCAmelCase_  )
									_snake_case						, _snake_case						, _snake_case						, _snake_case						, _snake_case   						=		self.h
									for i in range(0    ,   80  ):
										if 0 <= i < 20:
											_snake_case   						=		(b & c) | ((~b) & d)
											_snake_case   						=		0X5_A_8_2_7_9_9_9
										elif 20 <= i < 40:
											_snake_case   						=		b ^ c ^ d
											_snake_case   						=		0X6_E_D_9_E_B_A_1
										elif 40 <= i < 60:
											_snake_case   						=		(b & c) | (b & d) | (c & d)
											_snake_case   						=		0X8_F_1_B_B_C_D_C
										elif 60 <= i < 80:
											_snake_case   						=		b ^ c ^ d
											_snake_case   						=		0XC_A_6_2_C_1_D_6
										_snake_case						, _snake_case						, _snake_case						, _snake_case						, _snake_case   						=		(
										    self.rotate(lowerCAmelCase_    ,   5  ) + f + e + k + expanded_block[i] & 0XF_F_F_F_F_F_F_F,
										    a,
										    self.rotate(lowerCAmelCase_    ,   30  ),
										    c,
										    d,
										)
									_snake_case   						=		(
									    self.h[0] + a & 0XF_F_F_F_F_F_F_F,
									    self.h[1] + b & 0XF_F_F_F_F_F_F_F,
									    self.h[2] + c & 0XF_F_F_F_F_F_F_F,
									    self.h[3] + d & 0XF_F_F_F_F_F_F_F,
									    self.h[4] + e & 0XF_F_F_F_F_F_F_F,
									)
								return ("{:08x}" * 5).format(*self.h  )







def 				SCREAMING_SNAKE_CASE__	(   )       ->	Optional[Any]:
	_snake_case   						=		b'Test String'
	assert SHAaHash(__A	).final_hash() == hashlib.shaa(__A	).hexdigest()  # noqa: S324







def 				SCREAMING_SNAKE_CASE__	(   )       ->	Any:
	_snake_case   						=		argparse.ArgumentParser(description='Process some strings or files'	)
	parser.add_argument(
	    '--string'			,				dest='input_string'			,				default='Hello World!! Welcome to Cryptography'			,				help='Hash the string'			,				)
	parser.add_argument('--file'			,				dest='input_file'			,				help='Hash contents of a file'	)
	_snake_case   						=		parser.parse_args()
	_snake_case   						=		args.input_string
	# In any case 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(__A			,				'utf-8'	)
	print(SHAaHash(__A	).final_hash()	)


if __name__ == "__main__":
					main()
					import doctest

					doctest.testmod()









"""simple docstring"""





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_lxmert import LxmertTokenizer


_SCREAMING_SNAKE_CASE					:				Union[str, Any]					    =						{'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

_SCREAMING_SNAKE_CASE					:				Union[str, Any]					    =						{
    '''vocab_file''': {
        '''unc-nlp/lxmert-base-uncased''': '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/vocab.txt''',
    },
    '''tokenizer_file''': {
        '''unc-nlp/lxmert-base-uncased''': (
            '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/tokenizer.json'''
        ),
    },
}

_SCREAMING_SNAKE_CASE					:				Any					    =						{
    '''unc-nlp/lxmert-base-uncased''': 512,
}

_SCREAMING_SNAKE_CASE					:				int					    =						{
    '''unc-nlp/lxmert-base-uncased''': {'''do_lower_case''': True},
}






class      a						(					__snake_case		):
    SCREAMING_SNAKE_CASE						:     int						= VOCAB_FILES_NAMES
    SCREAMING_SNAKE_CASE						:     Optional[Any]						= PRETRAINED_VOCAB_FILES_MAP
    SCREAMING_SNAKE_CASE						:     Any						= PRETRAINED_INIT_CONFIGURATION
    SCREAMING_SNAKE_CASE						:     Any						= PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    SCREAMING_SNAKE_CASE						:     Optional[Any]						= LxmertTokenizer






    def __init__(       self     :							str       ,						__SCREAMING_SNAKE_CASE     :							Optional[Any]=None       ,						__SCREAMING_SNAKE_CASE     :							Optional[Any]=None       ,						__SCREAMING_SNAKE_CASE     :							str=True       ,						__SCREAMING_SNAKE_CASE     :							List[Any]="[UNK]"       ,						__SCREAMING_SNAKE_CASE     :							int="[SEP]"       ,						__SCREAMING_SNAKE_CASE     :							int="[PAD]"       ,						__SCREAMING_SNAKE_CASE     :							List[Any]="[CLS]"       ,						__SCREAMING_SNAKE_CASE     :							Any="[MASK]"       ,						__SCREAMING_SNAKE_CASE     :							List[str]=True       ,						__SCREAMING_SNAKE_CASE     :							List[str]=None       ,						**__SCREAMING_SNAKE_CASE     :							Any       ,						)     ->		Any:
      super().__init__(
          __SCREAMING_SNAKE_CASE       ,						tokenizer_file=__SCREAMING_SNAKE_CASE       ,						do_lower_case=__SCREAMING_SNAKE_CASE       ,						unk_token=__SCREAMING_SNAKE_CASE       ,						sep_token=__SCREAMING_SNAKE_CASE       ,						pad_token=__SCREAMING_SNAKE_CASE       ,						cls_token=__SCREAMING_SNAKE_CASE       ,						mask_token=__SCREAMING_SNAKE_CASE       ,						tokenize_chinese_chars=__SCREAMING_SNAKE_CASE       ,						strip_accents=__SCREAMING_SNAKE_CASE       ,						**__SCREAMING_SNAKE_CASE       ,						)

      lowerCamelCase_         =						json.loads(self.backend_tokenizer.normalizer.__getstate__()					)
      if (
          normalizer_state.get('lowercase'       ,						__SCREAMING_SNAKE_CASE					) != do_lower_case
          or normalizer_state.get('strip_accents'       ,						__SCREAMING_SNAKE_CASE					) != strip_accents
          or normalizer_state.get('handle_chinese_chars'       ,						__SCREAMING_SNAKE_CASE					) != tokenize_chinese_chars
      ):
        lowerCamelCase_         =						getattr(__SCREAMING_SNAKE_CASE       ,						normalizer_state.pop('type'					)					)
        lowerCamelCase_         =						do_lower_case
        lowerCamelCase_         =						strip_accents
        lowerCamelCase_         =						tokenize_chinese_chars
        lowerCamelCase_         =						normalizer_class(**__SCREAMING_SNAKE_CASE					)

      lowerCamelCase_         =						do_lower_case






    def    UpperCamelCase       (       self     :							Tuple       ,						__SCREAMING_SNAKE_CASE     :							Union[str, Any]       ,						__SCREAMING_SNAKE_CASE     :							Tuple=None					)     ->		Dict:
      lowerCamelCase_         =						[self.cls_token_id] + token_ids_a + [self.sep_token_id]

      if token_ids_a:
        output += token_ids_a + [self.sep_token_id]

      return output






    def    UpperCamelCase       (       self     :							str       ,						__SCREAMING_SNAKE_CASE     :							List[int]       ,						__SCREAMING_SNAKE_CASE     :							Optional[List[int]] = None					)     ->		List[int]:
      lowerCamelCase_         =						[self.sep_token_id]
      lowerCamelCase_         =						[self.cls_token_id]
      if token_ids_a is None:
        return len(cls + token_ids_a + sep					) * [0]
      return len(cls + token_ids_a + sep					) * [0] + len(token_ids_a + sep					) * [1]






    def    UpperCamelCase       (       self     :							List[str]       ,						__SCREAMING_SNAKE_CASE     :							str       ,						__SCREAMING_SNAKE_CASE     :							Optional[str] = None					)     ->		Tuple[str]:
      lowerCamelCase_         =						self._tokenizer.model.save(__SCREAMING_SNAKE_CASE       ,						name=__SCREAMING_SNAKE_CASE					)
      return tuple(__SCREAMING_SNAKE_CASE					)




