






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


__A					=	logging.get_logger(__name__)

__A					=	{
    "microsoft/cvt-13": "https://huggingface.co/microsoft/cvt-13/resolve/main/config.json",
    # See all Cvt models at https://huggingface.co/models?filter=cvt
}



class 				_A			(     UpperCamelCase				):
    """simple docstring"""

    lowerCamelCase	:							Union[str, Any]				= 'cvt'



    def __init__(				self      :     Any ,     __SCREAMING_SNAKE_CASE      :     Optional[int]=3 ,     __SCREAMING_SNAKE_CASE      :     List[Any]=[7, 3, 3] ,     __SCREAMING_SNAKE_CASE      :     Any=[4, 2, 2] ,     __SCREAMING_SNAKE_CASE      :     List[Any]=[2, 1, 1] ,     __SCREAMING_SNAKE_CASE      :     List[str]=[64, 192, 384] ,     __SCREAMING_SNAKE_CASE      :     Any=[1, 3, 6] ,     __SCREAMING_SNAKE_CASE      :     Optional[int]=[1, 2, 10] ,     __SCREAMING_SNAKE_CASE      :     str=[4.0, 4.0, 4.0] ,     __SCREAMING_SNAKE_CASE      :     int=[0.0, 0.0, 0.0] ,     __SCREAMING_SNAKE_CASE      :     List[str]=[0.0, 0.0, 0.0] ,     __SCREAMING_SNAKE_CASE      :     Tuple=[0.0, 0.0, 0.1] ,     __SCREAMING_SNAKE_CASE      :     Optional[Any]=[True, True, True] ,     __SCREAMING_SNAKE_CASE      :     str=[False, False, True] ,     __SCREAMING_SNAKE_CASE      :     Union[str, Any]=["dw_bn", "dw_bn", "dw_bn"] ,     __SCREAMING_SNAKE_CASE      :     List[Any]=[3, 3, 3] ,     __SCREAMING_SNAKE_CASE      :     List[str]=[1, 1, 1] ,     __SCREAMING_SNAKE_CASE      :     Union[str, Any]=[2, 2, 2] ,     __SCREAMING_SNAKE_CASE      :     Dict=[1, 1, 1] ,     __SCREAMING_SNAKE_CASE      :     Dict=[1, 1, 1] ,     __SCREAMING_SNAKE_CASE      :     Dict=0.02 ,     __SCREAMING_SNAKE_CASE      :     Tuple=1e-12 ,     **__SCREAMING_SNAKE_CASE      :     int ,     )      ->							Optional[int]:
           super().__init__(**__SCREAMING_SNAKE_CASE      )
           __UpperCAmelCase     				=num_channels
           __UpperCAmelCase     				=patch_sizes
           __UpperCAmelCase     				=patch_stride
           __UpperCAmelCase     				=patch_padding
           __UpperCAmelCase     				=embed_dim
           __UpperCAmelCase     				=num_heads
           __UpperCAmelCase     				=depth
           __UpperCAmelCase     				=mlp_ratio
           __UpperCAmelCase     				=attention_drop_rate
           __UpperCAmelCase     				=drop_rate
           __UpperCAmelCase     				=drop_path_rate
           __UpperCAmelCase     				=qkv_bias
           __UpperCAmelCase     				=cls_token
           __UpperCAmelCase     				=qkv_projection_method
           __UpperCAmelCase     				=kernel_qkv
           __UpperCAmelCase     				=padding_kv
           __UpperCAmelCase     				=stride_kv
           __UpperCAmelCase     				=padding_q
           __UpperCAmelCase     				=stride_q
           __UpperCAmelCase     				=initializer_range
           __UpperCAmelCase     				=layer_norm_eps





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


			'''simple docstring'''






			def 				a_			(  self):




					"""simple docstring"""


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




					"""simple docstring"""


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

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



			def 				a_			(  self):




					"""simple docstring"""


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

					lowerCAmelCase     =    DisjunctiveConstraint(__lowerCAmelCase)

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

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

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




					"""simple docstring"""


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

					lowerCAmelCase     =    DisjunctiveConstraint(__lowerCAmelCase)

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

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

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

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

					dc.reset()

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

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

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




