




'''simple docstring'''


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





class    __lowercase						:







   def __init__(	self      ,							UpperCamelCase      )				->    int:
     __a			=					data
     __a			=					[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 		UpperCamelCase__			(	UpperCamelCase      ,							UpperCamelCase      )				->    Optional[Any]:
     return ((n << b) | (n >> (32 - b))) & 0xF_F_F_F_F_F_F_F







   def 		UpperCamelCase__			(	self      )				->    str:
     __a			=					b'\x80' + b'\x00' * (63 - (len(self.data      ) + 8) % 64)
     __a			=					self.data + padding + struct.pack('>Q'      ,							8 * len(self.data      )      )
     return padded_data







   def 		UpperCamelCase__			(	self      )				->    Optional[Any]:
     return [
         self.padded_data[i : i + 64] for i in range(0      ,							len(self.padded_data      )      ,							64      )
     ]







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







   def 		UpperCamelCase__			(	self      )				->    str:
     __a			=					self.padding()
     __a			=					self.split_blocks()
     for block in self.blocks:
       __a			=					self.expand_block(UpperCamelCase      )
       __a	,       __a	,       __a	,       __a	,       __a			=					self.h
       for i in range(0      ,							80      ):
         if 0 <= i < 20:
           __a			=					(b & c) | ((~b) & d)
           __a			=					0x5_A_8_2_7_9_9_9
         elif 20 <= i < 40:
           __a			=					b ^ c ^ d
           __a			=					0x6_E_D_9_E_B_A_1
         elif 40 <= i < 60:
           __a			=					(b & c) | (b & d) | (c & d)
           __a			=					0x8_F_1_B_B_C_D_C
         elif 60 <= i < 80:
           __a			=					b ^ c ^ d
           __a			=					0xC_A_6_2_C_1_D_6
         __a	,       __a	,       __a	,       __a	,       __a			=					(
             self.rotate(UpperCamelCase      ,							5      ) + f + e + k + expanded_block[i] & 0xF_F_F_F_F_F_F_F,
             a,
             self.rotate(UpperCamelCase      ,							30      ),
             c,
             d,
         )
       __a			=					(
           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       (      ):
  __a			=					B'Test String'
  assert SHAaHash(a_			).final_hash() == hashlib.shaa(a_			).hexdigest()  # noqa: S324


def 						SCREAMING_SNAKE_CASE       (      ):
  __a			=					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'			)
  __a			=					parser.parse_args()
  __a			=					args.input_string
  # In any case hash input should be a bytestring
  if args.input_file:
    with open(args.input_file				,					'rb'			) as f:
      __a			=					f.read()
  else:
    __a			=					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 tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_roformer import RoFormerTokenizer
from .tokenization_utils import JiebaPreTokenizer


UpperCAmelCase_ 		=      logging.get_logger(__name__)

UpperCAmelCase_ 		=      {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

UpperCAmelCase_ 		=      {
    "vocab_file": {
        "junnyu/roformer_chinese_small": "https://huggingface.co/junnyu/roformer_chinese_small/resolve/main/vocab.txt",
        "junnyu/roformer_chinese_base": "https://huggingface.co/junnyu/roformer_chinese_base/resolve/main/vocab.txt",
        "junnyu/roformer_chinese_char_small": (
            "https://huggingface.co/junnyu/roformer_chinese_char_small/resolve/main/vocab.txt"
        ),
        "junnyu/roformer_chinese_char_base": (
            "https://huggingface.co/junnyu/roformer_chinese_char_base/resolve/main/vocab.txt"
        ),
        "junnyu/roformer_small_discriminator": (
            "https://huggingface.co/junnyu/roformer_small_discriminator/resolve/main/vocab.txt"
        ),
        "junnyu/roformer_small_generator": (
            "https://huggingface.co/junnyu/roformer_small_generator/resolve/main/vocab.txt"
        ),
    }
}

UpperCAmelCase_ 		=      {
    "junnyu/roformer_chinese_small": 15_36,
    "junnyu/roformer_chinese_base": 15_36,
    "junnyu/roformer_chinese_char_small": 5_12,
    "junnyu/roformer_chinese_char_base": 5_12,
    "junnyu/roformer_small_discriminator": 1_28,
    "junnyu/roformer_small_generator": 1_28,
}


UpperCAmelCase_ 		=      {
    "junnyu/roformer_chinese_small": {"do_lower_case": True},
    "junnyu/roformer_chinese_base": {"do_lower_case": True},
    "junnyu/roformer_chinese_char_small": {"do_lower_case": True},
    "junnyu/roformer_chinese_char_base": {"do_lower_case": True},
    "junnyu/roformer_small_discriminator": {"do_lower_case": True},
    "junnyu/roformer_small_generator": {"do_lower_case": True},
}





class    __lowercase						(  __magic_name__ ):
   _a							=      VOCAB_FILES_NAMES
   _a							=      PRETRAINED_VOCAB_FILES_MAP
   _a							=      PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   _a							=      PRETRAINED_INIT_CONFIGURATION
   _a							=      RoFormerTokenizer







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

     __a			=					json.loads(self.backend_tokenizer.normalizer.__getstate__()      )
     if (
         pre_tok_state.get('lowercase'      ,							UpperCamelCase      ) != do_lower_case
         or pre_tok_state.get('strip_accents'      ,							UpperCamelCase      ) != strip_accents
     ):
       __a			=					getattr(UpperCamelCase      ,							pre_tok_state.pop('type'      )      )
       __a			=					do_lower_case
       __a			=					strip_accents
       __a			=					pre_tok_class(**UpperCamelCase      )

     __a			=					do_lower_case







   def __getstate__(	self      )				->    List[Any]:
     __a			=					self.__dict__.copy()
     __a			=					BertPreTokenizer()
     return state







   def __setstate__(	self      ,							UpperCamelCase      )				->    Optional[int]:
     __a			=					d
     __a			=					self.__dict__['_tokenizer'].get_vocab()
     __a			=					PreTokenizer.custom(JiebaPreTokenizer(UpperCamelCase      )      )







   def 		UpperCamelCase__			(	self      ,							UpperCamelCase      ,							UpperCamelCase=None      )				->    int:
     __a			=					[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      ,							UpperCamelCase      ,							UpperCamelCase = None      )				->    List[int]:
     __a			=					[self.sep_token_id]
     __a			=					[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      ,							UpperCamelCase      ,							UpperCamelCase = None      )				->    Tuple[str]:
     __a			=					self._tokenizer.model.save(UpperCamelCase      ,							name=UpperCamelCase      )
     return tuple(UpperCamelCase      )







   def 		UpperCamelCase__			(	self      ,							UpperCamelCase      ,							UpperCamelCase=None      ,							UpperCamelCase=None      ,							UpperCamelCase=False      ,							**UpperCamelCase      ,							)				->    List[Any]:
     __a			=					BertPreTokenizer()
     return super().save_pretrained(UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      ,							**UpperCamelCase      )



