






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 	lowerCamelCase_       (							self:       Tuple  ):
														# For consistency across different places the DisjunctiveConstraint is called,
														# dc.token_ids is a list of integers. It is also initialized only by integers.

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

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

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




							def 	lowerCamelCase_       (							self:       List[str]  ):
														# 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).
														lowerCamelCase__      :			Union[str, Any] 						= [[1, 2], [1, 2, 3, 4]]

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




							def 	lowerCamelCase_       (							self:       Optional[Any]  ):
														lowerCamelCase__      :			List[Any] 						= [[1, 2, 3], [1, 2, 4]]

														lowerCamelCase__      :			Union[str, Any] 						= DisjunctiveConstraint(UpperCamelCase__  )

														lowerCamelCase__      :			Optional[Any] 						= dc.update(1  )
														lowerCamelCase__      :			Optional[int] 						= stepped is True and completed is False and reset is False
														self.assertTrue(UpperCamelCase__  )
														self.assertTrue(not dc.completed  )
														self.assertTrue(dc.current_seq == [1]  )

														lowerCamelCase__      :			int 						= dc.update(2  )
														lowerCamelCase__      :			Any 						= stepped is True and completed is False and reset is False
														self.assertTrue(UpperCamelCase__  )
														self.assertTrue(not dc.completed  )
														self.assertTrue(dc.current_seq == [1, 2]  )

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




							def 	lowerCamelCase_       (							self:       Optional[int]  ):
														lowerCamelCase__      :			List[str] 						= [[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

														lowerCamelCase__      :			Optional[int] 						= DisjunctiveConstraint(UpperCamelCase__  )

														lowerCamelCase__      :			List[str] 						= dc.update(1  )
														self.assertTrue(not dc.completed  )
														self.assertTrue(dc.current_seq == [1]  )

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

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

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

														dc.reset()

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

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

														lowerCamelCase__      :			Tuple 						= dc.update(5  )
														self.assertTrue(dc.completed  )  # Completed!
														self.assertTrue(dc.remaining() == 0  )
														self.assertTrue(dc.current_seq == [1, 2, 5]  )









'''simple docstring'''







from ...configuration_utils import PretrainedConfig
from ...utils import logging


_A			:    Union[str, Any]					  =logging.get_logger(__name__)

_A			:    List[str]					  ={
    '''MIT/ast-finetuned-audioset-10-10-0.4593''': (
        '''https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/config.json'''
    ),
}

class _lowercase			(       _lowercase	):
							a          = """audio-spectrogram-transformer"""




							def __init__(							self:       str    ,							UpperCamelCase__:       Any=768    ,							UpperCamelCase__:       Union[str, Any]=12    ,							UpperCamelCase__:       List[Any]=12    ,							UpperCamelCase__:       int=3_072    ,							UpperCamelCase__:       Optional[Any]="gelu"    ,							UpperCamelCase__:       Optional[int]=0.0    ,							UpperCamelCase__:       Tuple=0.0    ,							UpperCamelCase__:       Union[str, Any]=0.02    ,							UpperCamelCase__:       Dict=1e-12    ,							UpperCamelCase__:       List[str]=16    ,							UpperCamelCase__:       List[str]=True    ,							UpperCamelCase__:       Any=10    ,							UpperCamelCase__:       List[str]=10    ,							UpperCamelCase__:       Any=1_024    ,							UpperCamelCase__:       Optional[Any]=128    ,							**UpperCamelCase__:       Union[str, Any]    ,							):
														super().__init__(**UpperCamelCase__  )

														lowerCamelCase__      :			List[Any] 						= hidden_size
														lowerCamelCase__      :			int 						= num_hidden_layers
														lowerCamelCase__      :			List[str] 						= num_attention_heads
														lowerCamelCase__      :			Optional[int] 						= intermediate_size
														lowerCamelCase__      :			List[Any] 						= hidden_act
														lowerCamelCase__      :			List[Any] 						= hidden_dropout_prob
														lowerCamelCase__      :			str 						= attention_probs_dropout_prob
														lowerCamelCase__      :			Dict 						= initializer_range
														lowerCamelCase__      :			List[str] 						= layer_norm_eps
														lowerCamelCase__      :			List[Any] 						= patch_size
														lowerCamelCase__      :			List[str] 						= qkv_bias
														lowerCamelCase__      :			Dict 						= frequency_stride
														lowerCamelCase__      :			List[Any] 						= time_stride
														lowerCamelCase__      :			str 						= max_length
														lowerCamelCase__      :			Dict 						= num_mel_bins

