

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 	_SCREAMING_SNAKE_CASE							(   self: str      ):

						'''simple docstring'''





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

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

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







	def 	_SCREAMING_SNAKE_CASE							(   self: List[str]      ):

						'''simple docstring'''





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

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







	def 	_SCREAMING_SNAKE_CASE							(   self: Union[str, Any]      ):

						'''simple docstring'''





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

						__magic_name__							=    DisjunctiveConstraint(__UpperCamelCase      )

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

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

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







	def 	_SCREAMING_SNAKE_CASE							(   self: Any      ):

						'''simple docstring'''





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

						__magic_name__							=    DisjunctiveConstraint(__UpperCamelCase      )

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

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

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

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

						dc.reset()

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

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

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







from __future__ import annotations




def 					_lowercase     (				a_				:					int				)				->	bool:




					'''simple docstring'''







					__magic_name__							=    str(a_				)
					return len(a_				) == 9 and set(a_				) == set('123456789'				)




def 					_lowercase     (				)				->	int | None:




					'''simple docstring'''







					for base_num in range(9_9_9_9					,4_9_9_9					,-1				):
										__magic_name__							=    1_0_0_0_0_2 * base_num
										if is_9_pandigital(a_				):
															return candidate

					for base_num in range(3_3_3					,9_9					,-1				):
										__magic_name__							=    1_0_0_2_0_0_3 * base_num
										if is_9_pandigital(a_				):
															return candidate

					return None


if __name__ == "__main__":
						print(f'''{solution() = }''')




