





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






							def  A_     ( self     :					List[Any]						)				->			Union[str, Any]:





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      str     =						[[1, 2, 4], [1, 2, 3, 4]]
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						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  A_     ( self     :					Union[str, Any]						)				->			Union[str, Any]:





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      List[Any]     =						[[1, 2], [1, 2, 3, 4]]

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






							def  A_     ( self     :					List[Any]						)				->			List[Any]:





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      Dict     =						[[1, 2, 3], [1, 2, 4]]

														SCREAMING_SNAKE_CASE__       :      Optional[Any]     =						DisjunctiveConstraint(_UpperCAmelCase						)

														SCREAMING_SNAKE_CASE__   ,SCREAMING_SNAKE_CASE__   ,SCREAMING_SNAKE_CASE__       :      int     =						dc.update(1						)
														SCREAMING_SNAKE_CASE__       :      Any     =						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]						)

														SCREAMING_SNAKE_CASE__   ,SCREAMING_SNAKE_CASE__   ,SCREAMING_SNAKE_CASE__       :      Dict     =						dc.update(2						)
														SCREAMING_SNAKE_CASE__       :      Tuple     =						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]						)

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





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      Optional[int]     =						[[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

														SCREAMING_SNAKE_CASE__       :      Optional[int]     =						DisjunctiveConstraint(_UpperCAmelCase						)

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













from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowerCamelCase :    Union[str, Any]  							= {
    '''configuration_bigbird_pegasus''': [
        '''BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''BigBirdPegasusConfig''',
        '''BigBirdPegasusOnnxConfig''',
    ],
}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowerCamelCase :    int  							= [
		    '''BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''BigBirdPegasusForCausalLM''',
		    '''BigBirdPegasusForConditionalGeneration''',
		    '''BigBirdPegasusForQuestionAnswering''',
		    '''BigBirdPegasusForSequenceClassification''',
		    '''BigBirdPegasusModel''',
		    '''BigBirdPegasusPreTrainedModel''',
		]


if TYPE_CHECKING:
		from .configuration_bigbird_pegasus import (
		    BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP,
		    BigBirdPegasusConfig,
		    BigBirdPegasusOnnxConfig,
		)

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_bigbird_pegasus import (
				    BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST,
				    BigBirdPegasusForCausalLM,
				    BigBirdPegasusForConditionalGeneration,
				    BigBirdPegasusForQuestionAnswering,
				    BigBirdPegasusForSequenceClassification,
				    BigBirdPegasusModel,
				    BigBirdPegasusPreTrainedModel,
				)


else:
		import sys

		_lowerCamelCase :    Optional[Any]  							= _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)






