
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							:							str ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		[[1, 2, 4], [1, 2, 3, 4]]
       __SCREAMING_SNAKE_CASE      :	Tuple					=		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							:							Union[str, Any] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Dict					=		[[1, 2], [1, 2, 3, 4]]

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



     def  UpperCAmelCase__							(				self							:							Optional[int] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Dict					=		[[1, 2, 3], [1, 2, 4]]

       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		DisjunctiveConstraint(_A )

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

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







       """simple docstring"""




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

       __SCREAMING_SNAKE_CASE      :	str					=		DisjunctiveConstraint(_A )

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

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


"""simple docstring"""


SCREAMING_SNAKE_CASE			  =  {}



def 						lowerCamelCase__      (				UpperCAmelCase_		,   UpperCAmelCase_		,   UpperCAmelCase_					)->				int:







       """simple docstring"""

       # if we are absent twice, or late 3 consecutive days,
       # no further prize strings are possible
       if late == 3 or absent == 2:
              return 0

       # if we have no days left, and have not failed any other rules,
       # we have a prize string
       if days == 0:
              return 1

       # No easy solution, so now we need to do the recursive calculation

       # First, check if the combination is already in the cache, and
       # if yes, return the stored value from there since we already
       # know the number of possible prize strings from this point on
       UpperCamelCase       			=		(days, absent, late)
       if key in cache:
              return cache[key]

       # now we calculate the three possible ways that can unfold from
       # this point on, depending on our attendance today

       # 1) if we are late (but not absent), the "absent" counter stays as
       # it is, but the "late" counter increases by one
       UpperCamelCase       			=		_calculate(days - 1		,   UpperCAmelCase_		,   late + 1					)

       # 2) if we are absent, the "absent" counter increases by 1, and the
       # "late" counter resets to 0
       UpperCamelCase       			=		_calculate(days - 1		,   absent + 1		,   0					)

       # 3) if we are on time, this resets the "late" counter and keeps the
       # absent counter
       UpperCamelCase       			=		_calculate(days - 1		,   UpperCAmelCase_		,   0					)

       UpperCamelCase       			=		state_late + state_absent + state_ontime

       UpperCamelCase       			=		prizestrings
       return prizestrings



def 						lowerCamelCase__      (				UpperCAmelCase_ = 30					)->				int:







       """simple docstring"""
       return _calculate(UpperCAmelCase_		,   absent=0		,   late=0					)


if __name__ == "__main__":
      print(solution())





