
from ..utils import DummyObject, requires_backends

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						List[str]   							=  ['sentencepiece']







							def __init__(						self  :  Optional[Any]      ,				*snake_case__  :  Any      ,				**snake_case__  :  Optional[int] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Union[str, Any]   							=  ['sentencepiece']







							def __init__(						self  :  Any      ,				*snake_case__  :  Optional[int]      ,				**snake_case__  :  int ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						int   							=  ['sentencepiece']







							def __init__(						self  :  int      ,				*snake_case__  :  Optional[Any]      ,				**snake_case__  :  Any ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						List[Any]   							=  ['sentencepiece']







							def __init__(						self  :  Optional[int]      ,				*snake_case__  :  Union[str, Any]      ,				**snake_case__  :  Union[str, Any] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Tuple   							=  ['sentencepiece']







							def __init__(						self  :  List[Any]      ,				*snake_case__  :  Union[str, Any]      ,				**snake_case__  :  List[Any] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Any   							=  ['sentencepiece']







							def __init__(						self  :  Union[str, Any]      ,				*snake_case__  :  Optional[int]      ,				**snake_case__  :  Optional[int] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						List[str]   							=  ['sentencepiece']







							def __init__(						self  :  int      ,				*snake_case__  :  Optional[Any]      ,				**snake_case__  :  Any ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Tuple   							=  ['sentencepiece']







							def __init__(						self  :  List[str]      ,				*snake_case__  :  Tuple      ,				**snake_case__  :  Any ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Optional[int]   							=  ['sentencepiece']







							def __init__(						self  :  int      ,				*snake_case__  :  List[Any]      ,				**snake_case__  :  Optional[int] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Dict   							=  ['sentencepiece']







							def __init__(						self  :  str      ,				*snake_case__  :  Tuple      ,				**snake_case__  :  Dict ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Optional[int]   							=  ['sentencepiece']







							def __init__(						self  :  int      ,				*snake_case__  :  Optional[Any]      ,				**snake_case__  :  Optional[Any] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Union[str, Any]   							=  ['sentencepiece']







							def __init__(						self  :  Optional[Any]      ,				*snake_case__  :  List[str]      ,				**snake_case__  :  Union[str, Any] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						List[Any]   							=  ['sentencepiece']







							def __init__(						self  :  str      ,				*snake_case__  :  Optional[Any]      ,				**snake_case__  :  Optional[Any] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Optional[Any]   							=  ['sentencepiece']







							def __init__(						self  :  List[str]      ,				*snake_case__  :  List[Any]      ,				**snake_case__  :  Any ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Any   							=  ['sentencepiece']







							def __init__(						self  :  Tuple      ,				*snake_case__  :  Tuple      ,				**snake_case__  :  Union[str, Any] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Optional[int]   							=  ['sentencepiece']







							def __init__(						self  :  Union[str, Any]      ,				*snake_case__  :  int      ,				**snake_case__  :  Optional[Any] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Optional[Any]   							=  ['sentencepiece']







							def __init__(						self  :  List[Any]      ,				*snake_case__  :  Optional[Any]      ,				**snake_case__  :  Union[str, Any] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						int   							=  ['sentencepiece']







							def __init__(						self  :  List[str]      ,				*snake_case__  :  str      ,				**snake_case__  :  Tuple ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						int   							=  ['sentencepiece']







							def __init__(						self  :  List[str]      ,				*snake_case__  :  Dict      ,				**snake_case__  :  List[str] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Optional[int]   							=  ['sentencepiece']







							def __init__(						self  :  Tuple      ,				*snake_case__  :  Any      ,				**snake_case__  :  Optional[Any] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						int   							=  ['sentencepiece']







							def __init__(						self  :  Any      ,				*snake_case__  :  Tuple      ,				**snake_case__  :  Optional[int] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Any   							=  ['sentencepiece']







							def __init__(						self  :  List[str]      ,				*snake_case__  :  str      ,				**snake_case__  :  Union[str, Any] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Optional[int]   							=  ['sentencepiece']







							def __init__(						self  :  List[str]      ,				*snake_case__  :  Optional[Any]      ,				**snake_case__  :  str ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Tuple   							=  ['sentencepiece']







							def __init__(						self  :  Dict      ,				*snake_case__  :  Any      ,				**snake_case__  :  int ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Tuple   							=  ['sentencepiece']







							def __init__(						self  :  Dict      ,				*snake_case__  :  Tuple      ,				**snake_case__  :  Optional[int] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Optional[Any]   							=  ['sentencepiece']







							def __init__(						self  :  Any      ,				*snake_case__  :  str      ,				**snake_case__  :  List[Any] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						List[Any]   							=  ['sentencepiece']







							def __init__(						self  :  int      ,				*snake_case__  :  List[str]      ,				**snake_case__  :  List[str] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						Union[str, Any]   							=  ['sentencepiece']







							def __init__(						self  :  str      ,				*snake_case__  :  Optional[int]      ,				**snake_case__  :  Dict ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						List[str]   							=  ['sentencepiece']







							def __init__(						self  :  Tuple      ,				*snake_case__  :  Optional[Any]      ,				**snake_case__  :  str ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						List[str]   							=  ['sentencepiece']







							def __init__(						self  :  Tuple      ,				*snake_case__  :  Dict      ,				**snake_case__  :  Optional[int] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )

class       a		(   metaclass=__UpperCAmelCase					):
							lowercase_		:						List[str]   							=  ['sentencepiece']







							def __init__(						self  :  Tuple      ,				*snake_case__  :  str      ,				**snake_case__  :  Optional[Any] ):
								"""simple docstring"""







								requires_backends(self      ,				["sentencepiece"] )








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       UpperCAmelCase__					(						self  :  Optional[int] ):
								"""simple docstring"""







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

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

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







							def       UpperCAmelCase__					(						self  :  Tuple ):
								"""simple docstring"""







								__lowerCAmelCase         =							[[1, 2], [1, 2, 3, 4]]

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







							def       UpperCAmelCase__					(						self  :  Union[str, Any] ):
								"""simple docstring"""







								__lowerCAmelCase         =							[[1, 2, 3], [1, 2, 4]]

								__lowerCAmelCase         =							DisjunctiveConstraint(snake_case__ )

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

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

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







							def       UpperCAmelCase__					(						self  :  Optional[Any] ):
								"""simple docstring"""







								__lowerCAmelCase         =							[[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

								__lowerCAmelCase         =							DisjunctiveConstraint(snake_case__ )

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

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

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

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

								dc.reset()

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

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

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






