



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




       """simple docstring"""






       def  A_   (     self):

             """simple docstring"""





             UpperCAmelCase_  :	Optional[Any]				      =		[[1, 2, 4], [1, 2, 3, 4]]
             UpperCAmelCase_  :	Any				      =		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  A_   (     self):

             """simple docstring"""





             UpperCAmelCase_  :	Union[str, Any]				      =		[[1, 2], [1, 2, 3, 4]]

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



       def  A_   (     self):

             """simple docstring"""





             UpperCAmelCase_  :	Optional[Any]				      =		[[1, 2, 3], [1, 2, 4]]

             UpperCAmelCase_  :	Union[str, Any]				      =		DisjunctiveConstraint(_lowerCamelCase)

             UpperCAmelCase_      ,      UpperCAmelCase_      ,      UpperCAmelCase_  :	List[Any]				      =		dc.update(1)
             UpperCAmelCase_  :	Dict				      =		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])

             UpperCAmelCase_      ,      UpperCAmelCase_      ,      UpperCAmelCase_  :	Dict				      =		dc.update(2)
             UpperCAmelCase_  :	Optional[int]				      =		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])

             UpperCAmelCase_      ,      UpperCAmelCase_      ,      UpperCAmelCase_  :	Optional[Any]				      =		dc.update(3)
             UpperCAmelCase_  :	Dict				      =		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  A_   (     self):

             """simple docstring"""





             UpperCAmelCase_  :	Union[str, Any]				      =		[[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

             UpperCAmelCase_  :	List[Any]				      =		DisjunctiveConstraint(_lowerCamelCase)

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

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

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

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

             dc.reset()

             UpperCAmelCase_      ,      UpperCAmelCase_      ,      UpperCAmelCase_  :	List[Any]				      =		dc.update(1)
             self.assertTrue(not dc.completed)
             self.assertTrue(dc.remaining() == 3)
             self.assertTrue(dc.current_seq == [1])

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

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





def    _snake_case (       __snake_case					,  __snake_case    )     ->     int:






      '''simple docstring'''







      return int((input_a, input_a).count(0    ) != 0    )







def    _snake_case (       )     ->     None:






      '''simple docstring'''







      assert nand_gate(0					,  0    ) == 1
      assert nand_gate(0					,  1    ) == 1
      assert nand_gate(1					,  0    ) == 1
      assert nand_gate(1					,  1    ) == 0


if __name__ == "__main__":
   print(nand_gate(0, 0))
   print(nand_gate(0, 1))
   print(nand_gate(1, 0))
   print(nand_gate(1, 1))
