





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

			"""simple docstring"""







			def   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase				:		Optional[Any]				   =			[[1, 2, 4], [1, 2, 3, 4]]
									UpperCamelCase				:		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   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase				:		Any				   =			[[1, 2], [1, 2, 3, 4]]

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







			def   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase				:		Union[str, Any]				   =			[[1, 2, 3], [1, 2, 4]]

									UpperCamelCase				:		Optional[Any]				   =			DisjunctiveConstraint(_A    )

									UpperCamelCase   ,						UpperCamelCase   ,						UpperCamelCase				:		Union[str, Any]				   =			dc.update(1    )
									UpperCamelCase				:		Dict				   =			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]    )

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

									UpperCamelCase   ,						UpperCamelCase   ,						UpperCamelCase				:		List[str]				   =			dc.update(3    )
									UpperCamelCase				:		Dict				   =			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   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase				:		List[Any]				   =			[[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

									UpperCamelCase				:		int				   =			DisjunctiveConstraint(_A    )

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

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

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

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

									dc.reset()

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

									UpperCamelCase   ,						UpperCamelCase   ,						UpperCamelCase				:		Optional[Any]				   =			dc.update(2    )
									self.assertTrue(not dc.completed    )
									self.assertTrue(dc.remaining() == 2    )
									self.assertTrue(dc.current_seq == [1, 2]    )

									UpperCamelCase   ,						UpperCamelCase   ,						UpperCamelCase				:		Any				   =			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_tf_available, is_torch_available


__snake_case				:      Optional[int]   		=			{
    """configuration_xlm""": ["""XLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMConfig""", """XLMOnnxConfig"""],
    """tokenization_xlm""": ["""XLMTokenizer"""],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__snake_case				:      Optional[Any]   		=			[
	    """XLM_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """XLMForMultipleChoice""",
	    """XLMForQuestionAnswering""",
	    """XLMForQuestionAnsweringSimple""",
	    """XLMForSequenceClassification""",
	    """XLMForTokenClassification""",
	    """XLMModel""",
	    """XLMPreTrainedModel""",
	    """XLMWithLMHeadModel""",
	]

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__snake_case				:      Optional[Any]   		=			[
	    """TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """TFXLMForMultipleChoice""",
	    """TFXLMForQuestionAnsweringSimple""",
	    """TFXLMForSequenceClassification""",
	    """TFXLMForTokenClassification""",
	    """TFXLMMainLayer""",
	    """TFXLMModel""",
	    """TFXLMPreTrainedModel""",
	    """TFXLMWithLMHeadModel""",
	]


if TYPE_CHECKING:
	from .configuration_xlm import XLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMConfig, XLMOnnxConfig
	from .tokenization_xlm import XLMTokenizer

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_xlm import (
		    XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
		    XLMForMultipleChoice,
		    XLMForQuestionAnswering,
		    XLMForQuestionAnsweringSimple,
		    XLMForSequenceClassification,
		    XLMForTokenClassification,
		    XLMModel,
		    XLMPreTrainedModel,
		    XLMWithLMHeadModel,
		)

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_xlm import (
		    TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFXLMForMultipleChoice,
		    TFXLMForQuestionAnsweringSimple,
		    TFXLMForSequenceClassification,
		    TFXLMForTokenClassification,
		    TFXLMMainLayer,
		    TFXLMModel,
		    TFXLMPreTrainedModel,
		    TFXLMWithLMHeadModel,
		)

else:
	import sys

	__snake_case				:      Union[str, Any]   		=			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


