


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






     def  a_					(			self		)       ->    int:
          _a						=		[[1, 2, 4], [1, 2, 3, 4]]
          _a						=		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  a_					(			self		)       ->    Dict:
          _a						=		[[1, 2], [1, 2, 3, 4]]

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






     def  a_					(			self		)       ->    Any:
          _a						=		[[1, 2, 3], [1, 2, 4]]

          _a						=		DisjunctiveConstraint(__lowerCAmelCase		)

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

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

          _a			,			_a			,			_a						=		dc.update(3		)
          _a						=		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  a_					(			self		)       ->    List[Any]:
          _a						=		[[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

          _a						=		DisjunctiveConstraint(__lowerCAmelCase		)

          _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]		)




'''simple docstring'''

from typing import TYPE_CHECKING

from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase__				     =		{
    "configuration_mctct": ["MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MCTCTConfig"],
    "feature_extraction_mctct": ["MCTCTFeatureExtractor"],
    "processing_mctct": ["MCTCTProcessor"],
}


try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowercase__				     =		[
       "MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST",
       "MCTCTForCTC",
       "MCTCTModel",
       "MCTCTPreTrainedModel",
   ]


if TYPE_CHECKING:
   from .configuration_mctct import MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP, MCTCTConfig
   from .feature_extraction_mctct import MCTCTFeatureExtractor
   from .processing_mctct import MCTCTProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_mctct import MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST, MCTCTForCTC, MCTCTModel, MCTCTPreTrainedModel

else:
   import sys

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

