



'''simple docstring'''




from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCamelCase__	:     Tuple    =			{
    '''configuration_openai''': ['''OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''OpenAIGPTConfig'''],
    '''tokenization_openai''': ['''OpenAIGPTTokenizer'''],
}

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__	:     Optional[Any]    =			['''OpenAIGPTTokenizerFast''']

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__	:     List[str]    =			[
						    '''OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''OpenAIGPTDoubleHeadsModel''',
						    '''OpenAIGPTForSequenceClassification''',
						    '''OpenAIGPTLMHeadModel''',
						    '''OpenAIGPTModel''',
						    '''OpenAIGPTPreTrainedModel''',
						    '''load_tf_weights_in_openai_gpt''',
						]

try:
						if not is_tf_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__	:     Dict    =			[
						    '''TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''TFOpenAIGPTDoubleHeadsModel''',
						    '''TFOpenAIGPTForSequenceClassification''',
						    '''TFOpenAIGPTLMHeadModel''',
						    '''TFOpenAIGPTMainLayer''',
						    '''TFOpenAIGPTModel''',
						    '''TFOpenAIGPTPreTrainedModel''',
						]


if TYPE_CHECKING:
						from .configuration_openai import OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP, OpenAIGPTConfig
						from .tokenization_openai import OpenAIGPTTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_openai_fast import OpenAIGPTTokenizerFast

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_openai import (
												    OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST,
												    OpenAIGPTDoubleHeadsModel,
												    OpenAIGPTForSequenceClassification,
												    OpenAIGPTLMHeadModel,
												    OpenAIGPTModel,
												    OpenAIGPTPreTrainedModel,
												    load_tf_weights_in_openai_gpt,
												)

						try:
												if not is_tf_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_tf_openai import (
												    TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST,
												    TFOpenAIGPTDoubleHeadsModel,
												    TFOpenAIGPTForSequenceClassification,
												    TFOpenAIGPTLMHeadModel,
												    TFOpenAIGPTMainLayer,
												    TFOpenAIGPTModel,
												    TFOpenAIGPTPreTrainedModel,
												)

else:
						import sys

						UpperCamelCase__	:     List[Any]    =			_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)




'''simple docstring'''




import torch
import torch.nn.functional as F

from diffusers import VQDiffusionScheduler

from .test_schedulers import SchedulerCommonTest






class 						_UpperCamelCase  (							lowerCamelCase__   ):


			'''simple docstring'''

			_A				:		int         =		(VQDiffusionScheduler,)

			def UpperCamelCase__ (							self					:			List[str]							,					**lowerCAmelCase__					:			Dict						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE	:		int   	=		{
					    """num_vec_classes""": 4_0_9_7,
					    """num_train_timesteps""": 1_0_0,
					}

					config.update(**lowerCAmelCase__						)
					return config

			def UpperCamelCase__ (							self					:			Dict							,					lowerCAmelCase__					:			int						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE	:		Dict   	=		4
					__SCREAMING_SNAKE_CASE	:		Tuple   	=		8
					__SCREAMING_SNAKE_CASE	:		int   	=		8

					__SCREAMING_SNAKE_CASE	:		Dict   	=		torch.randint(0							,					lowerCAmelCase__							,					(batch_size, height * width)						)

					return sample

			@property
			def UpperCamelCase__ (							self					:			str						):





					"""simple docstring"""






					assert False

			def UpperCamelCase__ (							self					:			Dict							,					lowerCAmelCase__					:			str						):





					"""simple docstring"""






					def model(lowerCAmelCase__					:			Optional[Any]							,					lowerCAmelCase__					:			Any							,					*lowerCAmelCase__					:			Optional[int]						):
							__SCREAMING_SNAKE_CASE	,						__SCREAMING_SNAKE_CASE	:		Optional[int]   	=		sample.shape
							__SCREAMING_SNAKE_CASE	:		Optional[Any]   	=		torch.rand((batch_size, num_vec_classes - 1, num_latent_pixels)						)
							__SCREAMING_SNAKE_CASE	:		str   	=		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, 1_0_0, 1_0_0_0]:
							self.check_over_configs(num_train_timesteps=lowerCAmelCase__						)

			def UpperCamelCase__ (							self					:			int						):





					"""simple docstring"""






					for num_vec_classes in [5, 1_0_0, 1_0_0_0, 4_0_0_0]:
							self.check_over_configs(num_vec_classes=lowerCAmelCase__						)

			def UpperCamelCase__ (							self					:			Any						):





					"""simple docstring"""






					for t in [0, 5_0, 9_9]:
							self.check_over_forward(time_step=lowerCAmelCase__						)



			def UpperCamelCase__ (							self					:			List[Any]						):





					"""simple docstring"""






					pass