





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 				a			(      unittest.TestCase			):






				def 			snake_case_    (  self					):

										"""simple docstring"""




										__SCREAMING_SNAKE_CASE:				Union[str, Any]           =   [[1, 2, 4], [1, 2, 3, 4]]
										__SCREAMING_SNAKE_CASE:				int           =   DisjunctiveConstraint(_lowerCAmelCase					)
										self.assertTrue(isinstance(dc.token_ids			, _lowerCAmelCase					)					)

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

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






				def 			snake_case_    (  self					):

										"""simple docstring"""




										__SCREAMING_SNAKE_CASE:				Optional[int]           =   [[1, 2], [1, 2, 3, 4]]

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






				def 			snake_case_    (  self					):

										"""simple docstring"""




										__SCREAMING_SNAKE_CASE:				Optional[int]           =   [[1, 2, 3], [1, 2, 4]]

										__SCREAMING_SNAKE_CASE:				Optional[Any]           =   DisjunctiveConstraint(_lowerCAmelCase					)

										__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE:				Dict           =   dc.update(1					)
										__SCREAMING_SNAKE_CASE:				Union[str, Any]           =   stepped is True and completed is False and reset is False
										self.assertTrue(_lowerCAmelCase					)
										self.assertTrue(not dc.completed					)
										self.assertTrue(dc.current_seq == [1]					)

										__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE:				Dict           =   dc.update(2					)
										__SCREAMING_SNAKE_CASE:				List[str]           =   stepped is True and completed is False and reset is False
										self.assertTrue(_lowerCAmelCase					)
										self.assertTrue(not dc.completed					)
										self.assertTrue(dc.current_seq == [1, 2]					)

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






				def 			snake_case_    (  self					):

										"""simple docstring"""




										__SCREAMING_SNAKE_CASE:				int           =   [[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

										__SCREAMING_SNAKE_CASE:				Union[str, Any]           =   DisjunctiveConstraint(_lowerCAmelCase					)

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

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

										__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE:				Tuple           =   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:				Optional[int]           =   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:				Optional[Any]           =   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:				Optional[int]           =   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:				int           =   dc.update(5					)
										self.assertTrue(dc.completed					)  # Completed!
										self.assertTrue(dc.remaining() == 0					)
										self.assertTrue(dc.current_seq == [1, 2, 5]					)










from ..utils import DummyObject, requires_backends





class 				a			(      metaclass=__lowercase			):
				SCREAMING_SNAKE_CASE__     :   List[Any]		      =     ['''torch''', '''scipy''']






				def __init__(  self			, *_lowerCAmelCase			, **_lowerCAmelCase					):

										"""simple docstring"""




										requires_backends(self			, ['''torch''', '''scipy''']					)






				@classmethod
				def 			snake_case_    (  cls			, *_lowerCAmelCase			, **_lowerCAmelCase					):

										"""simple docstring"""




										requires_backends(cls			, ['''torch''', '''scipy''']					)






				@classmethod
				def 			snake_case_    (  cls			, *_lowerCAmelCase			, **_lowerCAmelCase					):

										"""simple docstring"""




										requires_backends(cls			, ['''torch''', '''scipy''']					)



