




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





       '''simple docstring'''






       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						[[1, 2, 4], [1, 2, 3, 4]]
             SCREAMING_SNAKE_CASE   :      List[Any]    					=						DisjunctiveConstraint(A  )
             self.assertTrue(isinstance(dc.token_ids,							A  )  )

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

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







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      str    					=						[[1, 2], [1, 2, 3, 4]]

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







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      List[Any]    					=						[[1, 2, 3], [1, 2, 4]]

             SCREAMING_SNAKE_CASE   :      List[str]    					=						DisjunctiveConstraint(A  )

             SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE   :      int    					=						dc.update(1  )
             SCREAMING_SNAKE_CASE   :      Dict    					=						stepped is True and completed is False and reset is False
             self.assertTrue(A  )
             self.assertTrue(not dc.completed  )
             self.assertTrue(dc.current_seq == [1]  )

             SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE   :      Tuple    					=						dc.update(2  )
             SCREAMING_SNAKE_CASE   :      int    					=						stepped is True and completed is False and reset is False
             self.assertTrue(A  )
             self.assertTrue(not dc.completed  )
             self.assertTrue(dc.current_seq == [1, 2]  )

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







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      List[str]    					=						[[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						DisjunctiveConstraint(A  )

             SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE   :      List[str]    					=						dc.update(1  )
             self.assertTrue(not dc.completed  )
             self.assertTrue(dc.current_seq == [1]  )

             SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE   :      Optional[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   :      Dict    					=						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   :      str    					=						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   :      List[str]    					=						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   :      Dict    					=						dc.update(5  )
             self.assertTrue(dc.completed  )  # Completed!
             self.assertTrue(dc.remaining() == 0  )
             self.assertTrue(dc.current_seq == [1, 2, 5]  )









'''simple docstring'''

from ..utils import DummyObject, requires_backends
class 							__lowerCAmelCase	(       metaclass=__magic_name__					):






       """simple docstring"""
       _snake_case      :	Dict									=       ['transformers', 'torch', 'note_seq']





       def __init__(				self  :						Tuple			,					*lowerCAmelCase__  :						List[str]			,					**lowerCAmelCase__  :						Optional[int]	)       ->	int:

            '''simple docstring'''




            requires_backends(self			,					['''transformers''', '''torch''', '''note_seq''']	)





       @classmethod
       def snake_case__		(				cls  :						Dict			,					*lowerCAmelCase__  :						Optional[Any]			,					**lowerCAmelCase__  :						Optional[int]	)       ->	Any:

            '''simple docstring'''




            requires_backends(cls			,					['''transformers''', '''torch''', '''note_seq''']	)







       @classmethod
       def snake_case__		(				cls  :						str			,					*lowerCAmelCase__  :						Any			,					**lowerCAmelCase__  :						List[Any]	)       ->	Tuple:

            '''simple docstring'''




            requires_backends(cls			,					['''transformers''', '''torch''', '''note_seq''']	)



