




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






						def 				__SCREAMING_SNAKE_CASE(   self			):




											"""simple docstring"""



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




											"""simple docstring"""



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

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






						def 				__SCREAMING_SNAKE_CASE(   self			):




											"""simple docstring"""



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

											__lowerCAmelCase				   =       DisjunctiveConstraint(_A			)

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

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

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




											"""simple docstring"""



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

											__lowerCAmelCase				   =       DisjunctiveConstraint(_A			)

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

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

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

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

											dc.reset()

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

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

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










from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels
from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features
from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassificationProcessor
from .xnli import xnli_output_modes, xnli_processors, xnli_tasks_num_labels




