


"""simple docstring"""







from ... import PretrainedConfig


a__				:							List[Any]						=     {
    '''sijunhe/nezha-cn-base''': '''https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json''',
}




class  UpperCamelCase_	( UpperCamelCase):

	"""simple docstring"""





	snake_case__				:  str    					=			NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP
	snake_case__				:  Optional[Any]    					=			"nezha"




	def __init__( self			:				Tuple			,			UpperCAmelCase__			:				Optional[Any]=2_1_1_2_8			,			UpperCAmelCase__			:				List[str]=7_6_8			,			UpperCAmelCase__			:				Union[str, Any]=1_2			,			UpperCAmelCase__			:				str=1_2			,			UpperCAmelCase__			:				Dict=3_0_7_2			,			UpperCAmelCase__			:				Any="gelu"			,			UpperCAmelCase__			:				List[str]=0.1			,			UpperCAmelCase__			:				Dict=0.1			,			UpperCAmelCase__			:				int=5_1_2			,			UpperCAmelCase__			:				Tuple=6_4			,			UpperCAmelCase__			:				Any=2			,			UpperCAmelCase__			:				str=0.02			,			UpperCAmelCase__			:				Optional[Any]=1E-12			,			UpperCAmelCase__			:				List[str]=0.1			,			UpperCAmelCase__			:				List[str]=0			,			UpperCAmelCase__			:				Optional[Any]=2			,			UpperCAmelCase__			:				List[Any]=3			,			UpperCAmelCase__			:				List[Any]=True			,			**UpperCAmelCase__			:				Any			,			)       ->	List[str]:
						super().__init__(pad_token_id=UpperCAmelCase__			,			bos_token_id=UpperCAmelCase__			,			eos_token_id=UpperCAmelCase__			,			**UpperCAmelCase__   )

						__SCREAMING_SNAKE_CASE						   =				vocab_size
						__SCREAMING_SNAKE_CASE						   =				hidden_size
						__SCREAMING_SNAKE_CASE						   =				num_hidden_layers
						__SCREAMING_SNAKE_CASE						   =				num_attention_heads
						__SCREAMING_SNAKE_CASE						   =				hidden_act
						__SCREAMING_SNAKE_CASE						   =				intermediate_size
						__SCREAMING_SNAKE_CASE						   =				hidden_dropout_prob
						__SCREAMING_SNAKE_CASE						   =				attention_probs_dropout_prob
						__SCREAMING_SNAKE_CASE						   =				max_position_embeddings
						__SCREAMING_SNAKE_CASE						   =				max_relative_position
						__SCREAMING_SNAKE_CASE						   =				type_vocab_size
						__SCREAMING_SNAKE_CASE						   =				initializer_range
						__SCREAMING_SNAKE_CASE						   =				layer_norm_eps
						__SCREAMING_SNAKE_CASE						   =				classifier_dropout
						__SCREAMING_SNAKE_CASE						   =				use_cache




"""simple docstring"""







import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
		import torch

		from transformers.generation import DisjunctiveConstraint




@require_torch
class  UpperCamelCase_	( unittest.TestCase):

	"""simple docstring"""





	def   UpperCAmelCase_      ( self			:				Optional[int]   )       ->	List[str]:
						# For consistency across different places the DisjunctiveConstraint is called,
						# dc.token_ids is a list of integers. It is also initialized only by integers.

						__SCREAMING_SNAKE_CASE						   =				[[1, 2, 4], [1, 2, 3, 4]]
						__SCREAMING_SNAKE_CASE						   =				DisjunctiveConstraint(UpperCAmelCase__   )
						self.assertTrue(isinstance(dc.token_ids			,			UpperCAmelCase__   )   )

						with self.assertRaises(UpperCAmelCase__   ):
											DisjunctiveConstraint(torch.LongTensor([[1, 2, 4], [1, 2, 3]]   )   )

						with self.assertRaises(UpperCAmelCase__   ):
											DisjunctiveConstraint([torch.LongTensor([1, 2, 4]   ), torch.LongTensor([1, 2, 3, 4, 5]   )]   )




	def   UpperCAmelCase_      ( self			:				Any   )       ->	int:
						# We can't have constraints that are complete subsets of another. This leads to a preverse
						# interpretation of "constraint fulfillment": does generating [1,2,3] fulfill the constraint?
						# It would mean that it generated [1,2] which fulfills it, but it's in the middle of potentially
						# fulfilling [1,2,3,4]. If we believe that [1,2,3] does fulfill the constraint, then the algorithm
						# will necessarily never reach [1,2,3,4], giving users a false sense of control (better to just not allow it).
						__SCREAMING_SNAKE_CASE						   =				[[1, 2], [1, 2, 3, 4]]

						with self.assertRaises(UpperCAmelCase__   ):
											DisjunctiveConstraint(UpperCAmelCase__   )  # fails here




	def   UpperCAmelCase_      ( self			:				List[Any]   )       ->	Any:
						__SCREAMING_SNAKE_CASE						   =				[[1, 2, 3], [1, 2, 4]]

						__SCREAMING_SNAKE_CASE						   =				DisjunctiveConstraint(UpperCAmelCase__   )

						__SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE						   =				dc.update(1   )
						__SCREAMING_SNAKE_CASE						   =				stepped is True and completed is False and reset is False
						self.assertTrue(UpperCAmelCase__   )
						self.assertTrue(not dc.completed   )
						self.assertTrue(dc.current_seq == [1]   )

						__SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE						   =				dc.update(2   )
						__SCREAMING_SNAKE_CASE						   =				stepped is True and completed is False and reset is False
						self.assertTrue(UpperCAmelCase__   )
						self.assertTrue(not dc.completed   )
						self.assertTrue(dc.current_seq == [1, 2]   )

						__SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE						   =				dc.update(3   )
						__SCREAMING_SNAKE_CASE						   =				stepped is True and completed is True and reset is False
						self.assertTrue(UpperCAmelCase__   )
						self.assertTrue(dc.completed   )  # Completed!
						self.assertTrue(dc.current_seq == [1, 2, 3]   )




	def   UpperCAmelCase_      ( self			:				str   )       ->	List[str]:
						__SCREAMING_SNAKE_CASE						   =				[[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

						__SCREAMING_SNAKE_CASE						   =				DisjunctiveConstraint(UpperCAmelCase__   )

						__SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE						   =				dc.update(1   )
						self.assertTrue(not dc.completed   )
						self.assertTrue(dc.current_seq == [1]   )

						__SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE						   =				dc.update(2   )
						self.assertTrue(not dc.completed   )
						self.assertTrue(dc.current_seq == [1, 2]   )

						__SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE						   =				dc.update(4   )
						self.assertTrue(not dc.completed   )
						self.assertTrue(dc.current_seq == [1, 2, 4]   )

						__SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE						   =				dc.update(5   )
						self.assertTrue(dc.completed   )  # Completed!
						self.assertTrue(dc.current_seq == [1, 2, 4, 5]   )

						dc.reset()

						__SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE						   =				dc.update(1   )
						self.assertTrue(not dc.completed   )
						self.assertTrue(dc.remaining() == 3   )
						self.assertTrue(dc.current_seq == [1]   )

						__SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE						   =				dc.update(2   )
						self.assertTrue(not dc.completed   )
						self.assertTrue(dc.remaining() == 2   )
						self.assertTrue(dc.current_seq == [1, 2]   )

						__SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE   ,  __SCREAMING_SNAKE_CASE						   =				dc.update(5   )
						self.assertTrue(dc.completed   )  # Completed!
						self.assertTrue(dc.remaining() == 0   )
						self.assertTrue(dc.current_seq == [1, 2, 5]   )
