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


							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






								_snake_case   						=		[[1, 2, 4], [1, 2, 3, 4]]
								_snake_case   						=		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  lowerCamelCase				(       self  ):





								"""simple docstring"""






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

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


							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






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

								_snake_case   						=		DisjunctiveConstraint(lowerCAmelCase_  )

								_snake_case						, _snake_case						, _snake_case   						=		dc.update(1  )
								_snake_case   						=		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]  )

								_snake_case						, _snake_case						, _snake_case   						=		dc.update(2  )
								_snake_case   						=		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]  )

								_snake_case						, _snake_case						, _snake_case   						=		dc.update(3  )
								_snake_case   						=		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  lowerCamelCase				(       self  ):





								"""simple docstring"""






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

								_snake_case   						=		DisjunctiveConstraint(lowerCAmelCase_  )

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

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

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

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

								dc.reset()

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

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

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




def 	snake_case__			(    SCREAMING_SNAKE_CASE_		:    str			):



     '''simple docstring'''





     if not all(char in '01' for char in bin_string			):
          raise ValueError('Non-binary value was passed to the function'			)
     if not bin_string:
          raise ValueError('Empty string was passed to the function'			)
     lowercase__    :   Union[str, Any]      =       ''
     while len(SCREAMING_SNAKE_CASE_			) % 3 != 0:
          lowercase__    :   List[str]      =       '0' + bin_string
     lowercase__    :   Any      =       [
         bin_string[index : index + 3]
         for index in range(len(SCREAMING_SNAKE_CASE_			)			)
         if index % 3 == 0
     ]
     for bin_group in bin_string_in_3_list:
          lowercase__    :   str      =       0
          for index, val in enumerate(SCREAMING_SNAKE_CASE_			):
               oct_val += int(2 ** (2 - index) * int(SCREAMING_SNAKE_CASE_			)			)
          oct_string += str(SCREAMING_SNAKE_CASE_			)
     return oct_string


if __name__ == "__main__":
       from doctest import testmod

       testmod()

