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



  """simple docstring"""






  def 	_UpperCAmelCase				(				self:			List[str]   ) -> List[str]:




    '''simple docstring'''




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

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

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






  def 	_UpperCAmelCase				(				self:			Optional[int]   ) -> Tuple:




    '''simple docstring'''




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

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






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




    '''simple docstring'''




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

    __UpperCAmelCase						    =       DisjunctiveConstraint(__lowerCAmelCase   )

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

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

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






  def 	_UpperCAmelCase				(				self:			Dict   ) -> List[Any]:




    '''simple docstring'''




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

    __UpperCAmelCase						    =       DisjunctiveConstraint(__lowerCAmelCase   )

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

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

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

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

    dc.reset()

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

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

    __UpperCAmelCase    ,		__UpperCAmelCase    ,		__UpperCAmelCase						    =       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_tokenizers_available, is_torch_available


a_							=      {
    """configuration_squeezebert""": [
        """SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """SqueezeBertConfig""",
        """SqueezeBertOnnxConfig""",
    ],
    """tokenization_squeezebert""": ["""SqueezeBertTokenizer"""],
}

try:
       if not is_tokenizers_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       a_							=      ["""SqueezeBertTokenizerFast"""]

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       a_							=      [
           """SQUEEZEBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
           """SqueezeBertForMaskedLM""",
           """SqueezeBertForMultipleChoice""",
           """SqueezeBertForQuestionAnswering""",
           """SqueezeBertForSequenceClassification""",
           """SqueezeBertForTokenClassification""",
           """SqueezeBertModel""",
           """SqueezeBertModule""",
           """SqueezeBertPreTrainedModel""",
       ]


if TYPE_CHECKING:
       from .configuration_squeezebert import (
           SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
           SqueezeBertConfig,
           SqueezeBertOnnxConfig,
       )
       from .tokenization_squeezebert import SqueezeBertTokenizer

       try:
              if not is_tokenizers_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .tokenization_squeezebert_fast import SqueezeBertTokenizerFast

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_squeezebert import (
                  SQUEEZEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                  SqueezeBertForMaskedLM,
                  SqueezeBertForMultipleChoice,
                  SqueezeBertForQuestionAnswering,
                  SqueezeBertForSequenceClassification,
                  SqueezeBertForTokenClassification,
                  SqueezeBertModel,
                  SqueezeBertModule,
                  SqueezeBertPreTrainedModel,
              )

else:
       import sys

       a_							=      _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



