




from ..utils import deprecate
from .attention_processor import (  # noqa: F401
    Attention,
    AttentionProcessor,
    AttnAddedKVProcessor,
    AttnProcessor2_0,
    LoRAAttnProcessor,
    LoRALinearLayer,
    LoRAXFormersAttnProcessor,
    SlicedAttnAddedKVProcessor,
    SlicedAttnProcessor,
    XFormersAttnProcessor,
)
from .attention_processor import AttnProcessor as AttnProcessorRename  # noqa: F401


deprecate(
    'cross_attention',
    '0.20.0',
    'Importing from cross_attention is deprecated. Please import from diffusers.models.attention_processor instead.',
    standard_warn=False,
)


lowercase_      :							Union[str, Any]    							=					AttentionProcessor






class        __lowerCAmelCase					(			UpperCAmelCase__					):







			def __init__(			self       :     Optional[Any]       ,       *snake_case__       :     Any       ,       **snake_case__       :     Optional[Any] ):




									"""simple docstring"""


									_UpperCAmelCase						=	F"""{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross" ) )} instead."""
									deprecate("cross_attention"       ,       "0.20.0"       ,       snake_case__       ,       standard_warn=snake_case__ )
									super().__init__(*snake_case__       ,       **snake_case__ )






class        __lowerCAmelCase					(			UpperCAmelCase__					):







			def __init__(			self       :     int       ,       *snake_case__       :     Dict       ,       **snake_case__       :     int ):




									"""simple docstring"""


									_UpperCAmelCase						=	F"""{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross" ) )} instead."""
									deprecate("cross_attention"       ,       "0.20.0"       ,       snake_case__       ,       standard_warn=snake_case__ )
									super().__init__(*snake_case__       ,       **snake_case__ )






class        __lowerCAmelCase					(			UpperCAmelCase__					):







			def __init__(			self       :     Union[str, Any]       ,       *snake_case__       :     List[str]       ,       **snake_case__       :     Dict ):




									"""simple docstring"""


									_UpperCAmelCase						=	F"""{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross" ) )} instead."""
									deprecate("cross_attention"       ,       "0.20.0"       ,       snake_case__       ,       standard_warn=snake_case__ )
									super().__init__(*snake_case__       ,       **snake_case__ )






class        __lowerCAmelCase					(			UpperCAmelCase__					):







			def __init__(			self       :     Optional[Any]       ,       *snake_case__       :     str       ,       **snake_case__       :     Optional[Any] ):




									"""simple docstring"""


									_UpperCAmelCase						=	F"""{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross" ) )} instead."""
									deprecate("cross_attention"       ,       "0.20.0"       ,       snake_case__       ,       standard_warn=snake_case__ )
									super().__init__(*snake_case__       ,       **snake_case__ )






class        __lowerCAmelCase					(			UpperCAmelCase__					):







			def __init__(			self       :     Union[str, Any]       ,       *snake_case__       :     int       ,       **snake_case__       :     Optional[int] ):




									"""simple docstring"""


									_UpperCAmelCase						=	F"""{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross" ) )} instead."""
									deprecate("cross_attention"       ,       "0.20.0"       ,       snake_case__       ,       standard_warn=snake_case__ )
									super().__init__(*snake_case__       ,       **snake_case__ )






class        __lowerCAmelCase					(			UpperCAmelCase__					):







			def __init__(			self       :     Union[str, Any]       ,       *snake_case__       :     Any       ,       **snake_case__       :     List[Any] ):




									"""simple docstring"""


									_UpperCAmelCase						=	F"""{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross" ) )} instead."""
									deprecate("cross_attention"       ,       "0.20.0"       ,       snake_case__       ,       standard_warn=snake_case__ )
									super().__init__(*snake_case__       ,       **snake_case__ )






class        __lowerCAmelCase					(			UpperCAmelCase__					):







			def __init__(			self       :     List[str]       ,       *snake_case__       :     int       ,       **snake_case__       :     Optional[int] ):




									"""simple docstring"""


									_UpperCAmelCase						=	F"""{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross" ) )} instead."""
									deprecate("cross_attention"       ,       "0.20.0"       ,       snake_case__       ,       standard_warn=snake_case__ )
									super().__init__(*snake_case__       ,       **snake_case__ )






class        __lowerCAmelCase					(			UpperCAmelCase__					):







			def __init__(			self       :     Any       ,       *snake_case__       :     Optional[int]       ,       **snake_case__       :     Tuple ):




									"""simple docstring"""


									_UpperCAmelCase						=	F"""{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross" ) )} instead."""
									deprecate("cross_attention"       ,       "0.20.0"       ,       snake_case__       ,       standard_warn=snake_case__ )
									super().__init__(*snake_case__       ,       **snake_case__ )










import torch
import torch.nn.functional as F

from diffusers import VQDiffusionScheduler

from .test_schedulers import SchedulerCommonTest






class        __lowerCAmelCase					(			UpperCAmelCase__					):
			snake_case_ :					List[str]						=	(VQDiffusionScheduler,)







			def UpperCamelCase     (			self       :     Dict       ,       **snake_case__       :     int ):




									"""simple docstring"""


									_UpperCAmelCase						=	{
									    "num_vec_classes": 4_097,
									    "num_train_timesteps": 100,
									}

									config.update(**snake_case__ )
									return config







			def UpperCamelCase     (			self       :     Optional[int]       ,       snake_case__       :     Any ):




									"""simple docstring"""


									_UpperCAmelCase						=	4
									_UpperCAmelCase						=	8
									_UpperCAmelCase						=	8

									_UpperCAmelCase						=	torch.randint(0       ,       snake_case__       ,       (batch_size, height * width) )

									return sample







			@property
			def UpperCamelCase     (			self       :     str ):




									"""simple docstring"""


									assert False







			def UpperCamelCase     (			self       :     List[str]       ,       snake_case__       :     Optional[Any] ):




									"""simple docstring"""


									def model(snake_case__       :     Dict       ,       snake_case__       :     Tuple       ,       *snake_case__       :     str ):
															_UpperCAmelCase				,					_UpperCAmelCase						=	sample.shape
															_UpperCAmelCase						=	torch.rand((batch_size, num_vec_classes - 1, num_latent_pixels) )
															_UpperCAmelCase						=	F.log_softmax(logits.double()       ,       dim=1 ).float()
															return return_value

									return model







			def UpperCamelCase     (			self       :     Optional[int] ):




									"""simple docstring"""


									for timesteps in [2, 5, 100, 1_000]:
															self.check_over_configs(num_train_timesteps=snake_case__ )







			def UpperCamelCase     (			self       :     Optional[int] ):




									"""simple docstring"""


									for num_vec_classes in [5, 100, 1_000, 4_000]:
															self.check_over_configs(num_vec_classes=snake_case__ )







			def UpperCamelCase     (			self       :     Optional[Any] ):




									"""simple docstring"""


									for t in [0, 50, 99]:
															self.check_over_forward(time_step=snake_case__ )







			def UpperCamelCase     (			self       :     Tuple ):




									"""simple docstring"""


									pass




