





'''simple docstring'''




import torch
import torch.nn.functional as F

from diffusers import VQDiffusionScheduler

from .test_schedulers import SchedulerCommonTest


class 						__UpperCamelCase (				lowerCamelCase__       ):
       lowercase			:					Any   		=(VQDiffusionScheduler,)






       def   lowercase__  (							self,	**lowerCAmelCase						):



              """simple docstring"""







              lowerCamelCase_							={
                  '''num_vec_classes''': 4_097,
                  '''num_train_timesteps''': 100,
              }

              config.update(**lowerCAmelCase						)
              return config






       def   lowercase__  (							self,	lowerCAmelCase						):



              """simple docstring"""







              lowerCamelCase_							=4
              lowerCamelCase_							=8
              lowerCamelCase_							=8

              lowerCamelCase_							=torch.randint(0,	lowerCAmelCase,	(batch_size, height * width)						)

              return sample






       @property
       def   lowercase__  (							self						):



              """simple docstring"""







              assert False






       def   lowercase__  (							self,	lowerCAmelCase						):



              """simple docstring"""







              def model(lowerCAmelCase,	lowerCAmelCase,	*lowerCAmelCase						):
                     lowerCamelCase_,   lowerCamelCase_							=sample.shape
                     lowerCamelCase_							=torch.rand((batch_size, num_vec_classes - 1, num_latent_pixels)						)
                     lowerCamelCase_							=F.log_softmax(logits.double(),	dim=1						).float()
                     return return_value

              return model






       def   lowercase__  (							self						):



              """simple docstring"""







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






       def   lowercase__  (							self						):



              """simple docstring"""







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






       def   lowercase__  (							self						):



              """simple docstring"""







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






       def   lowercase__  (							self						):



              """simple docstring"""







              pass










'''simple docstring'''




from typing import TYPE_CHECKING

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


a_   :	Union[str, Any]							   = {
    """configuration_openai""": ["""OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """OpenAIGPTConfig"""],
    """tokenization_openai""": ["""OpenAIGPTTokenizer"""],
}

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     a_   :	Optional[int]							   = ["""OpenAIGPTTokenizerFast"""]

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     a_   :	int							   = [
         """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:
     a_   :	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

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




