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



							def 	UpperCamelCase	(						self    ):
													# For consistency across different places the DisjunctiveConstraint is called,
													# dc.token_ids is a list of integers. It is also initialized only by integers.

													_snake_case						:					List[str]    =   [[1, 2, 4], [1, 2, 3, 4]]
													_snake_case						:					List[Any]    =   DisjunctiveConstraint(lowercase_    )
													self.assertTrue(isinstance(dc.token_ids				,    lowercase_    )    )

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

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



							def 	UpperCamelCase	(						self    ):
													# We can't have constraints that are complete subsets of another. This leads to a preverse
													# interpretation of "constraint fulfillment": does generating [1,2,3] fulfill the constraint?
													# It would mean that it generated [1,2] which fulfills it, but it's in the middle of potentially
													# fulfilling [1,2,3,4]. If we believe that [1,2,3] does fulfill the constraint, then the algorithm
													# will necessarily never reach [1,2,3,4], giving users a false sense of control (better to just not allow it).
													_snake_case						:					Union[str, Any]    =   [[1, 2], [1, 2, 3, 4]]

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



							def 	UpperCamelCase	(						self    ):
													_snake_case						:					Optional[int]    =   [[1, 2, 3], [1, 2, 4]]

													_snake_case						:					List[str]    =   DisjunctiveConstraint(lowercase_    )

													_snake_case						:					int    =   dc.update(1    )
													_snake_case						:					str    =   stepped is True and completed is False and reset is False
													self.assertTrue(lowercase_    )
													self.assertTrue(not dc.completed    )
													self.assertTrue(dc.current_seq == [1]    )

													_snake_case						:					Tuple    =   dc.update(2    )
													_snake_case						:					Dict    =   stepped is True and completed is False and reset is False
													self.assertTrue(lowercase_    )
													self.assertTrue(not dc.completed    )
													self.assertTrue(dc.current_seq == [1, 2]    )

													_snake_case						:					Dict    =   dc.update(3    )
													_snake_case						:					List[str]    =   stepped is True and completed is True and reset is False
													self.assertTrue(lowercase_    )
													self.assertTrue(dc.completed    )  # Completed!
													self.assertTrue(dc.current_seq == [1, 2, 3]    )



							def 	UpperCamelCase	(						self    ):
													_snake_case						:					Dict    =   [[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

													_snake_case						:					str    =   DisjunctiveConstraint(lowercase_    )

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

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

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

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

													dc.reset()

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

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

													_snake_case						:					int    =   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_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__SCREAMING_SNAKE_CASE						:   Optional[int]         =			{
    'configuration_distilbert': [
        'DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'DistilBertConfig',
        'DistilBertOnnxConfig',
    ],
    'tokenization_distilbert': ['DistilBertTokenizer'],
}

try:
				if not is_tokenizers_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__SCREAMING_SNAKE_CASE						:   Optional[int]         =			['DistilBertTokenizerFast']

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__SCREAMING_SNAKE_CASE						:   int         =			[
				    'DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'DistilBertForMaskedLM',
				    'DistilBertForMultipleChoice',
				    'DistilBertForQuestionAnswering',
				    'DistilBertForSequenceClassification',
				    'DistilBertForTokenClassification',
				    'DistilBertModel',
				    'DistilBertPreTrainedModel',
				]

try:
				if not is_tf_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__SCREAMING_SNAKE_CASE						:   Any         =			[
				    'TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'TFDistilBertForMaskedLM',
				    'TFDistilBertForMultipleChoice',
				    'TFDistilBertForQuestionAnswering',
				    'TFDistilBertForSequenceClassification',
				    'TFDistilBertForTokenClassification',
				    'TFDistilBertMainLayer',
				    'TFDistilBertModel',
				    'TFDistilBertPreTrainedModel',
				]

try:
				if not is_flax_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__SCREAMING_SNAKE_CASE						:   Optional[Any]         =			[
				    'FlaxDistilBertForMaskedLM',
				    'FlaxDistilBertForMultipleChoice',
				    'FlaxDistilBertForQuestionAnswering',
				    'FlaxDistilBertForSequenceClassification',
				    'FlaxDistilBertForTokenClassification',
				    'FlaxDistilBertModel',
				    'FlaxDistilBertPreTrainedModel',
				]


if TYPE_CHECKING:
				from .configuration_distilbert import (
				    DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
				    DistilBertConfig,
				    DistilBertOnnxConfig,
				)
				from .tokenization_distilbert import DistilBertTokenizer

				try:
								if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_distilbert_fast import DistilBertTokenizerFast

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_distilbert import (
								    DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    DistilBertForMaskedLM,
								    DistilBertForMultipleChoice,
								    DistilBertForQuestionAnswering,
								    DistilBertForSequenceClassification,
								    DistilBertForTokenClassification,
								    DistilBertModel,
								    DistilBertPreTrainedModel,
								)

				try:
								if not is_tf_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_tf_distilbert import (
								    TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    TFDistilBertForMaskedLM,
								    TFDistilBertForMultipleChoice,
								    TFDistilBertForQuestionAnswering,
								    TFDistilBertForSequenceClassification,
								    TFDistilBertForTokenClassification,
								    TFDistilBertMainLayer,
								    TFDistilBertModel,
								    TFDistilBertPreTrainedModel,
								)

				try:
								if not is_flax_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_flax_distilbert import (
								    FlaxDistilBertForMaskedLM,
								    FlaxDistilBertForMultipleChoice,
								    FlaxDistilBertForQuestionAnswering,
								    FlaxDistilBertForSequenceClassification,
								    FlaxDistilBertForTokenClassification,
								    FlaxDistilBertModel,
								    FlaxDistilBertPreTrainedModel,
								)

else:
				import sys

				__SCREAMING_SNAKE_CASE						:   str         =			_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)