

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



       '''simple docstring'''







       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             __A    =[[1, 2, 4], [1, 2, 3, 4]]
             __A    =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     ):







             '''simple docstring'''



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

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

       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



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

             __A    =DisjunctiveConstraint(lowercase__     )

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

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

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







             '''simple docstring'''



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

             __A    =DisjunctiveConstraint(lowercase__     )

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

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

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

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

             dc.reset()

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

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

             __A    ,		__A    ,		__A    =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_speech_available, is_torch_available


_lowerCamelCase      :					int					    =      {
    '''configuration_audio_spectrogram_transformer''': [
        '''AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''ASTConfig''',
    ]
}

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _lowerCamelCase      :					Tuple					    =      [
       '''AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''ASTForAudioClassification''',
       '''ASTModel''',
       '''ASTPreTrainedModel''',
   ]

try:
   if not is_speech_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _lowerCamelCase      :					Optional[Any]					    =      ['''ASTFeatureExtractor''']

if TYPE_CHECKING:
   from .configuration_audio_spectrogram_transformer import (
       AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
       ASTConfig,
   )

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_audio_spectrogram_transformer import (
          AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
          ASTForAudioClassification,
          ASTModel,
          ASTPreTrainedModel,
      )

   try:
      if not is_speech_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .feature_extraction_audio_spectrogram_transformer import ASTFeatureExtractor


else:
   import sys

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


