


'''simple docstring'''



import argparse
import struct
import unittest





class 							__UpperCamelCase				:




	def __init__(   self						,				__a							):

						'''simple docstring'''





						__a			:       Optional[Any]					    =  data

						# Initialize hash values
						__a			:       Optional[int]					    =  [
						    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			:       Union[str, 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			:       Optional[int]					    =  self.preprocessing(self.data							)
						self.final_hash()




	@staticmethod
	def       __UpperCAmelCase							(   __a							):

						'''simple docstring'''





						__a			:       Optional[int]					    =  b'\x80' + (b'\x00' * (63 - (len(__a							) + 8) % 64))
						__a			:       Dict					    =  struct.pack('>Q'						,				(len(__a							) * 8)							)
						return data + padding + big_endian_integer




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       List[Any]					    =  [
						    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'						,				__a							)							)
											# add 48 0-ed integers
											words += [0] * 48

											__a			:       Tuple					    =  self.hashes

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

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

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

																__a			:       Union[str, Any]					    =  (
																    g,
																    f,
																    e,
																    ((d + tempa) % 0x1_00_00_00_00),
																    c,
																    b,
																    a,
																    ((tempa + tempa) % 0x1_00_00_00_00),
																)

											__a			:       Any					    =  [a, b, c, d, e, f, g, h]

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

						__a			:       Optional[Any]					    =  ''.join([hex(__a							)[2:].zfill(8							) for value in self.hashes]							)





	def       __UpperCAmelCase							(   self						,				__a						,				__a							):

						'''simple docstring'''





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





class 							__UpperCamelCase				(		unittest.TestCase					):




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						import hashlib

						__a			:       Dict					    =  bytes('Test String'						,				'utf-8'							)
						self.assertEqual(SHAaaa(__a							).hash						,				hashlib.shaaaa(__a							).hexdigest()							)






def   lowerCamelCase							():
					import doctest

					doctest.testmod()

					__a			:       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			:       Any					    =  parser.parse_args()

					__a			:       int					    =  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			:       Optional[int]					    =  bytes(SCREAMING_SNAKE_CASE_						,      'utf-8'   )

					print(SHAaaa(SCREAMING_SNAKE_CASE_   ).hash   )


if __name__ == "__main__":
	main()





import os
import tempfile
import unittest

from transformers import NezhaConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
					import torch

					from transformers import (
					    MODEL_FOR_PRETRAINING_MAPPING,
					    NezhaForMaskedLM,
					    NezhaForMultipleChoice,
					    NezhaForNextSentencePrediction,
					    NezhaForPreTraining,
					    NezhaForQuestionAnswering,
					    NezhaForSequenceClassification,
					    NezhaForTokenClassification,
					    NezhaModel,
					)
					from transformers.models.nezha.modeling_nezha import NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST







class      A__							:






				def __init__(						self					:      str    ,     a					:      Optional[Any]    ,     a					:      int=13    ,     a					:      str=7    ,     a					:      str=True    ,     a					:      List[str]=True    ,     a					:      Optional[Any]=True    ,     a					:      int=True    ,     a					:      List[Any]=99    ,     a					:      List[Any]=32    ,     a					:      Tuple=5    ,     a					:      Any=4    ,     a					:      Optional[int]=37    ,     a					:      Tuple="gelu"    ,     a					:      Any=0.1    ,     a					:      int=0.1    ,     a					:      List[Any]=128    ,     a					:      Union[str, Any]=32    ,     a					:      Union[str, Any]=16    ,     a					:      Dict=2    ,     a					:      List[Any]=0.0_2    ,     a					:      Optional[Any]=3    ,     a					:      List[Any]=4    ,     a					:      Optional[int]=None    ,     ):






							'''simple docstring'''







							lowerCAmelCase__      :      Optional[Any]         =		parent
							lowerCAmelCase__      :      Dict         =		batch_size
							lowerCAmelCase__      :      Optional[Any]         =		seq_length
							lowerCAmelCase__      :      Optional[Any]         =		is_training
							lowerCAmelCase__      :      Union[str, Any]         =		use_input_mask
							lowerCAmelCase__      :      List[Any]         =		use_token_type_ids
							lowerCAmelCase__      :      str         =		use_labels
							lowerCAmelCase__      :      Optional[Any]         =		vocab_size
							lowerCAmelCase__      :      Union[str, Any]         =		hidden_size
							lowerCAmelCase__      :      Optional[int]         =		num_hidden_layers
							lowerCAmelCase__      :      Optional[int]         =		num_attention_heads
							lowerCAmelCase__      :      List[Any]         =		intermediate_size
							lowerCAmelCase__      :      List[str]         =		hidden_act
							lowerCAmelCase__      :      List[Any]         =		hidden_dropout_prob
							lowerCAmelCase__      :      Optional[int]         =		attention_probs_dropout_prob
							lowerCAmelCase__      :      Dict         =		max_position_embeddings
							lowerCAmelCase__      :      Any         =		type_vocab_size
							lowerCAmelCase__      :      Any         =		type_sequence_label_size
							lowerCAmelCase__      :      List[Any]         =		initializer_range
							lowerCAmelCase__      :      Dict         =		num_labels
							lowerCAmelCase__      :      Any         =		num_choices
							lowerCAmelCase__      :      Union[str, Any]         =		scope






				def 							_lowerCamelCase		(						self					:      Dict   ):






							'''simple docstring'''







							lowerCAmelCase__      :      int         =		ids_tensor([self.batch_size, self.seq_length]    ,     self.vocab_size   )

							lowerCAmelCase__      :      Tuple         =		None
							if self.use_input_mask:
										lowerCAmelCase__      :      Tuple         =		random_attention_mask([self.batch_size, self.seq_length]   )

							lowerCAmelCase__      :      Tuple         =		None
							if self.use_token_type_ids:
										lowerCAmelCase__      :      List[Any]         =		ids_tensor([self.batch_size, self.seq_length]    ,     self.type_vocab_size   )

							lowerCAmelCase__      :      Optional[int]         =		None
							lowerCAmelCase__      :      Optional[Any]         =		None
							lowerCAmelCase__      :      Optional[int]         =		None
							if self.use_labels:
										lowerCAmelCase__      :      Any         =		ids_tensor([self.batch_size]    ,     self.type_sequence_label_size   )
										lowerCAmelCase__      :      Union[str, Any]         =		ids_tensor([self.batch_size, self.seq_length]    ,     self.num_labels   )
										lowerCAmelCase__      :      List[Any]         =		ids_tensor([self.batch_size]    ,     self.num_choices   )

							lowerCAmelCase__      :      Dict         =		self.get_config()

							return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels






				def 							_lowerCamelCase		(						self					:      List[Any]   ):






							'''simple docstring'''







							return NezhaConfig(
							    vocab_size=self.vocab_size    ,     hidden_size=self.hidden_size    ,     num_hidden_layers=self.num_hidden_layers    ,     num_attention_heads=self.num_attention_heads    ,     intermediate_size=self.intermediate_size    ,     hidden_act=self.hidden_act    ,     hidden_dropout_prob=self.hidden_dropout_prob    ,     attention_probs_dropout_prob=self.attention_probs_dropout_prob    ,     max_position_embeddings=self.max_position_embeddings    ,     type_vocab_size=self.type_vocab_size    ,     is_decoder=a    ,     initializer_range=self.initializer_range    ,     )






				def 							_lowerCamelCase		(						self					:      Optional[Any]   ):






							'''simple docstring'''







							(
							    (
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				
							)      :      List[Any]         =		self.prepare_config_and_inputs()

							lowerCAmelCase__      :      List[Any]         =		True
							lowerCAmelCase__      :      Tuple         =		floats_tensor([self.batch_size, self.seq_length, self.hidden_size]   )
							lowerCAmelCase__      :      Tuple         =		ids_tensor([self.batch_size, self.seq_length]    ,     vocab_size=2   )

							return (
							    config,
							    input_ids,
							    token_type_ids,
							    input_mask,
							    sequence_labels,
							    token_labels,
							    choice_labels,
							    encoder_hidden_states,
							    encoder_attention_mask,
							)






				def 							_lowerCamelCase		(						self					:      Optional[Any]    ,     a					:      Optional[int]    ,     a					:      Tuple    ,     a					:      Optional[int]    ,     a					:      List[Any]    ,     a					:      Tuple    ,     a					:      List[str]    ,     a					:      Any   ):






							'''simple docstring'''







							lowerCAmelCase__      :      List[str]         =		NezhaModel(config=a   )
							model.to(a   )
							model.eval()
							lowerCAmelCase__      :      Dict         =		model(a    ,     attention_mask=a    ,     token_type_ids=a   )
							lowerCAmelCase__      :      List[str]         =		model(a    ,     token_type_ids=a   )
							lowerCAmelCase__      :      Any         =		model(a   )
							self.parent.assertEqual(result.last_hidden_state.shape    ,     (self.batch_size, self.seq_length, self.hidden_size)   )
							self.parent.assertEqual(result.pooler_output.shape    ,     (self.batch_size, self.hidden_size)   )






				def 							_lowerCamelCase		(						self					:      List[Any]    ,     a					:      Union[str, Any]    ,     a					:      Dict    ,     a					:      List[Any]    ,     a					:      Optional[Any]    ,     a					:      int    ,     a					:      Tuple    ,     a					:      List[Any]    ,     a					:      Tuple    ,     a					:      List[str]    ,     ):






							'''simple docstring'''







							lowerCAmelCase__      :      Union[str, Any]         =		True
							lowerCAmelCase__      :      Optional[int]         =		NezhaModel(a   )
							model.to(a   )
							model.eval()
							lowerCAmelCase__      :      Any         =		model(
							    a    ,     attention_mask=a    ,     token_type_ids=a    ,     encoder_hidden_states=a    ,     encoder_attention_mask=a    ,     )
							lowerCAmelCase__      :      Dict         =		model(
							    a    ,     attention_mask=a    ,     token_type_ids=a    ,     encoder_hidden_states=a    ,     )
							lowerCAmelCase__      :      List[str]         =		model(a    ,     attention_mask=a    ,     token_type_ids=a   )
							self.parent.assertEqual(result.last_hidden_state.shape    ,     (self.batch_size, self.seq_length, self.hidden_size)   )
							self.parent.assertEqual(result.pooler_output.shape    ,     (self.batch_size, self.hidden_size)   )






				def 							_lowerCamelCase		(						self					:      Tuple    ,     a					:      Optional[Any]    ,     a					:      List[Any]    ,     a					:      str    ,     a					:      List[str]    ,     a					:      Tuple    ,     a					:      List[Any]    ,     a					:      Optional[Any]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      List[Any]         =		NezhaForMaskedLM(config=a   )
							model.to(a   )
							model.eval()
							lowerCAmelCase__      :      Dict         =		model(a    ,     attention_mask=a    ,     token_type_ids=a    ,     labels=a   )
							self.parent.assertEqual(result.logits.shape    ,     (self.batch_size, self.seq_length, self.vocab_size)   )






				def 							_lowerCamelCase		(						self					:      List[Any]    ,     a					:      Optional[int]    ,     a					:      List[Any]    ,     a					:      int    ,     a					:      List[str]    ,     a					:      Union[str, Any]    ,     a					:      int    ,     a					:      Any   ):






							'''simple docstring'''







							lowerCAmelCase__      :      List[Any]         =		NezhaForNextSentencePrediction(config=a   )
							model.to(a   )
							model.eval()
							lowerCAmelCase__      :      str         =		model(
							    a    ,     attention_mask=a    ,     token_type_ids=a    ,     labels=a    ,     )
							self.parent.assertEqual(result.logits.shape    ,     (self.batch_size, 2)   )






				def 							_lowerCamelCase		(						self					:      int    ,     a					:      Optional[int]    ,     a					:      str    ,     a					:      List[str]    ,     a					:      int    ,     a					:      Dict    ,     a					:      Optional[Any]    ,     a					:      Optional[Any]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Tuple         =		NezhaForPreTraining(config=a   )
							model.to(a   )
							model.eval()
							lowerCAmelCase__      :      Optional[int]         =		model(
							    a    ,     attention_mask=a    ,     token_type_ids=a    ,     labels=a    ,     next_sentence_label=a    ,     )
							self.parent.assertEqual(result.prediction_logits.shape    ,     (self.batch_size, self.seq_length, self.vocab_size)   )
							self.parent.assertEqual(result.seq_relationship_logits.shape    ,     (self.batch_size, 2)   )






				def 							_lowerCamelCase		(						self					:      Union[str, Any]    ,     a					:      Dict    ,     a					:      List[str]    ,     a					:      Any    ,     a					:      Any    ,     a					:      Union[str, Any]    ,     a					:      Tuple    ,     a					:      List[Any]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Optional[Any]         =		NezhaForQuestionAnswering(config=a   )
							model.to(a   )
							model.eval()
							lowerCAmelCase__      :      Tuple         =		model(
							    a    ,     attention_mask=a    ,     token_type_ids=a    ,     start_positions=a    ,     end_positions=a    ,     )
							self.parent.assertEqual(result.start_logits.shape    ,     (self.batch_size, self.seq_length)   )
							self.parent.assertEqual(result.end_logits.shape    ,     (self.batch_size, self.seq_length)   )






				def 							_lowerCamelCase		(						self					:      Tuple    ,     a					:      str    ,     a					:      Union[str, Any]    ,     a					:      Tuple    ,     a					:      Optional[Any]    ,     a					:      Dict    ,     a					:      str    ,     a					:      int   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Any         =		self.num_labels
							lowerCAmelCase__      :      Optional[Any]         =		NezhaForSequenceClassification(a   )
							model.to(a   )
							model.eval()
							lowerCAmelCase__      :      Tuple         =		model(a    ,     attention_mask=a    ,     token_type_ids=a    ,     labels=a   )
							self.parent.assertEqual(result.logits.shape    ,     (self.batch_size, self.num_labels)   )






				def 							_lowerCamelCase		(						self					:      List[str]    ,     a					:      Dict    ,     a					:      str    ,     a					:      Optional[Any]    ,     a					:      Optional[int]    ,     a					:      List[str]    ,     a					:      Dict    ,     a					:      str   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Dict         =		self.num_labels
							lowerCAmelCase__      :      str         =		NezhaForTokenClassification(config=a   )
							model.to(a   )
							model.eval()
							lowerCAmelCase__      :      Any         =		model(a    ,     attention_mask=a    ,     token_type_ids=a    ,     labels=a   )
							self.parent.assertEqual(result.logits.shape    ,     (self.batch_size, self.seq_length, self.num_labels)   )






				def 							_lowerCamelCase		(						self					:      int    ,     a					:      Tuple    ,     a					:      List[Any]    ,     a					:      Tuple    ,     a					:      List[Any]    ,     a					:      Optional[int]    ,     a					:      Optional[int]    ,     a					:      Optional[Any]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Optional[Any]         =		self.num_choices
							lowerCAmelCase__      :      Any         =		NezhaForMultipleChoice(config=a   )
							model.to(a   )
							model.eval()
							lowerCAmelCase__      :      int         =		input_ids.unsqueeze(1   ).expand(-1    ,     self.num_choices    ,     -1   ).contiguous()
							lowerCAmelCase__      :      str         =		token_type_ids.unsqueeze(1   ).expand(-1    ,     self.num_choices    ,     -1   ).contiguous()
							lowerCAmelCase__      :      Optional[Any]         =		input_mask.unsqueeze(1   ).expand(-1    ,     self.num_choices    ,     -1   ).contiguous()
							lowerCAmelCase__      :      Any         =		model(
							    a    ,     attention_mask=a    ,     token_type_ids=a    ,     labels=a    ,     )
							self.parent.assertEqual(result.logits.shape    ,     (self.batch_size, self.num_choices)   )






				def 							_lowerCamelCase		(						self					:      Tuple   ):






							'''simple docstring'''







							lowerCAmelCase__      :      int         =		self.prepare_config_and_inputs()
							(
							    (
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				
							)      :      Any         =		config_and_inputs
							lowerCAmelCase__      :      str         =		{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
							return config, inputs_dict







@require_torch
class      A__							(     __magic_name__						,   __magic_name__						,   __magic_name__						,   unittest.TestCase	):
				lowercase			    =  (
				    (
				        NezhaModel,
				        NezhaForMaskedLM,
				        NezhaForMultipleChoice,
				        NezhaForNextSentencePrediction,
				        NezhaForPreTraining,
				        NezhaForQuestionAnswering,
				        NezhaForSequenceClassification,
				        NezhaForTokenClassification,
				    )
				    if is_torch_available()
				    else ()
				)
				lowercase			    =  (
				    {
				        'feature-extraction': NezhaModel,
				        'fill-mask': NezhaForMaskedLM,
				        'question-answering': NezhaForQuestionAnswering,
				        'text-classification': NezhaForSequenceClassification,
				        'token-classification': NezhaForTokenClassification,
				        'zero-shot': NezhaForSequenceClassification,
				    }
				    if is_torch_available()
				    else {}
				)
				lowercase			    =  True






				def 							_lowerCamelCase		(						self					:      str    ,     a					:      Tuple    ,     a					:      int    ,     a					:      Dict=False   ):






							'''simple docstring'''







							lowerCAmelCase__      :      int         =		super()._prepare_for_class(a    ,     a    ,     return_labels=a   )

							if return_labels:
										if model_class in get_values(a   ):
													lowerCAmelCase__      :      Tuple         =		torch.zeros(
													    (self.model_tester.batch_size, self.model_tester.seq_length)    ,     dtype=torch.long    ,     device=a   )
													lowerCAmelCase__      :      Optional[Any]         =		torch.zeros(
													    self.model_tester.batch_size    ,     dtype=torch.long    ,     device=a   )
							return inputs_dict






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






							'''simple docstring'''







							lowerCAmelCase__      :      Optional[int]         =		NezhaModelTester(self   )
							lowerCAmelCase__      :      Optional[int]         =		ConfigTester(self    ,     config_class=a    ,     hidden_size=37   )






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






							'''simple docstring'''







							self.config_tester.run_common_tests()






				def 							_lowerCamelCase		(						self					:      Optional[int]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      List[str]         =		self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*a   )






				def 							_lowerCamelCase		(						self					:      List[str]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      int         =		self.model_tester.prepare_config_and_inputs_for_decoder()
							self.model_tester.create_and_check_model_as_decoder(*a   )






				def 							_lowerCamelCase		(						self					:      Optional[Any]   ):






							'''simple docstring'''







							(
							    (
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				(
							    lowerCAmelCase__
							)      ,				
							)      :      str         =		self.model_tester.prepare_config_and_inputs_for_decoder()

							lowerCAmelCase__      :      str         =		None

							self.model_tester.create_and_check_model_as_decoder(
							    a    ,     a    ,     a    ,     a    ,     a    ,     a    ,     a    ,     a    ,     a    ,     )






				def 							_lowerCamelCase		(						self					:      int   ):






							'''simple docstring'''







							lowerCAmelCase__      :      int         =		self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_masked_lm(*a   )






				def 							_lowerCamelCase		(						self					:      List[Any]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Union[str, Any]         =		self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_multiple_choice(*a   )






				def 							_lowerCamelCase		(						self					:      int   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Optional[int]         =		self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_next_sequence_prediction(*a   )






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






							'''simple docstring'''







							lowerCAmelCase__      :      List[str]         =		self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_pretraining(*a   )






				def 							_lowerCamelCase		(						self					:      int   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Optional[int]         =		self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_question_answering(*a   )






				def 							_lowerCamelCase		(						self					:      Optional[Any]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      int         =		self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_sequence_classification(*a   )






				def 							_lowerCamelCase		(						self					:      List[Any]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Any         =		self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_token_classification(*a   )






				@slow
				def 							_lowerCamelCase		(						self					:      Union[str, Any]   ):






							'''simple docstring'''







							for model_name in NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										lowerCAmelCase__      :      Optional[Any]         =		NezhaModel.from_pretrained(a   )
										self.assertIsNotNone(a   )






				@slow
				@require_torch_gpu
				def 							_lowerCamelCase		(						self					:      Optional[int]   ):






							'''simple docstring'''







							lowerCAmelCase__      ,				lowerCAmelCase__      :      Optional[int]         =		self.model_tester.prepare_config_and_inputs_for_common()
							for model_class in self.all_model_classes:
										# NezhaForMultipleChoice behaves incorrectly in JIT environments.
										if model_class == NezhaForMultipleChoice:
													return

										lowerCAmelCase__      :      Dict         =		True
										lowerCAmelCase__      :      Any         =		model_class(config=a   )

										lowerCAmelCase__      :      Union[str, Any]         =		self._prepare_for_class(a    ,     a   )
										lowerCAmelCase__      :      int         =		torch.jit.trace(
										    a    ,     (inputs_dict['input_ids'].to('cpu'   ), inputs_dict['attention_mask'].to('cpu'   ))   )

										with tempfile.TemporaryDirectory() as tmp:
													torch.jit.save(a    ,     os.path.join(a    ,     'bert.pt'   )   )
													lowerCAmelCase__      :      Any         =		torch.jit.load(os.path.join(a    ,     'bert.pt'   )    ,     map_location=a   )
													loaded(inputs_dict['input_ids'].to(a   )    ,     inputs_dict['attention_mask'].to(a   )   )







@require_torch
class      A__							(     unittest.TestCase	):






				@slow
				def 							_lowerCamelCase		(						self					:      Optional[int]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      str         =		NezhaModel.from_pretrained('sijunhe/nezha-cn-base'   )
							lowerCAmelCase__      :      Any         =		torch.tensor([[0, 1, 2, 3, 4, 5]]   )
							lowerCAmelCase__      :      Union[str, Any]         =		torch.tensor([[0, 1, 1, 1, 1, 1]]   )
							with torch.no_grad():
										lowerCAmelCase__      :      Optional[int]         =		model(a    ,     attention_mask=a   )[0]
							lowerCAmelCase__      :      Union[str, Any]         =		torch.Size((1, 6, 768)   )
							self.assertEqual(output.shape    ,     a   )
							lowerCAmelCase__      :      Optional[int]         =		torch.tensor([[[0.0_6_8_5, 0.2_4_4_1, 0.1_1_0_2], [0.0_6_0_0, 0.1_9_0_6, 0.1_3_4_9], [0.0_2_2_1, 0.0_8_1_9, 0.0_5_8_6]]]   )

							self.assertTrue(torch.allclose(output[:, 1:4, 1:4]    ,     a    ,     atol=1E-4   )   )






				@slow
				def 							_lowerCamelCase		(						self					:      List[Any]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Any         =		NezhaForMaskedLM.from_pretrained('sijunhe/nezha-cn-base'   )
							lowerCAmelCase__      :      Optional[int]         =		torch.tensor([[0, 1, 2, 3, 4, 5]]   )
							lowerCAmelCase__      :      Optional[int]         =		torch.tensor([[1, 1, 1, 1, 1, 1]]   )
							with torch.no_grad():
										lowerCAmelCase__      :      Optional[int]         =		model(a    ,     attention_mask=a   )[0]
							lowerCAmelCase__      :      int         =		torch.Size((1, 6, 21_128)   )
							self.assertEqual(output.shape    ,     a   )
							lowerCAmelCase__      :      List[Any]         =		torch.tensor(
							    [[-2.7_9_3_9, -1.7_9_0_2, -2.2_1_8_9], [-2.8_5_8_5, -1.8_9_0_8, -2.3_7_2_3], [-2.6_4_9_9, -1.7_7_5_0, -2.2_5_5_8]]   )

							self.assertTrue(torch.allclose(output[:, 1:4, 1:4]    ,     a    ,     atol=1E-4   )   )