



"""simple docstring"""






import unittest
from dataclasses import dataclass
from typing import List, Union

import numpy as np
import PIL.Image

from diffusers.utils.outputs import BaseOutput

@dataclass
class 			__SCREAMING_SNAKE_CASE      ( lowerCAmelCase_  ):


					'''simple docstring'''





					_a       =				42





class 			__SCREAMING_SNAKE_CASE      ( unittest.TestCase  ):


					'''simple docstring'''





					def 						snake_case			(			self				:    List[str]	)->   str:
								lowerCamelCase__						:						Dict						      =CustomOutput(images=np.random.rand(1,    3,    4,    4	)	)

								# check every way of getting the attribute
								assert isinstance(outputs.images,    np.ndarray	)
								assert outputs.images.shape == (1, 3, 4, 4)
								assert isinstance(outputs['''images'''],    np.ndarray	)
								assert outputs["images"].shape == (1, 3, 4, 4)
								assert isinstance(outputs[0],    np.ndarray	)
								assert outputs[0].shape == (1, 3, 4, 4)

								# test with a non-tensor attribute
								lowerCamelCase__						:						Any						      =CustomOutput(images=[PIL.Image.new('''RGB''',    (4, 4)	)]	)

								# check every way of getting the attribute
								assert isinstance(outputs.images,    lowerCamelCase	)
								assert isinstance(outputs.images[0],    PIL.Image.Image	)
								assert isinstance(outputs['''images'''],    lowerCamelCase	)
								assert isinstance(outputs['''images'''][0],    PIL.Image.Image	)
								assert isinstance(outputs[0],    lowerCamelCase	)
								assert isinstance(outputs[0][0],    PIL.Image.Image	)




					def 						snake_case			(			self				:    Tuple	)->   Optional[int]:
								# test output reinitialization with a `dict` for compatibility with `accelerate`
								lowerCamelCase__						:						Optional[Any]						      =CustomOutput({'''images''': np.random.rand(1,    3,    4,    4	)}	)

								# check every way of getting the attribute
								assert isinstance(outputs.images,    np.ndarray	)
								assert outputs.images.shape == (1, 3, 4, 4)
								assert isinstance(outputs['''images'''],    np.ndarray	)
								assert outputs["images"].shape == (1, 3, 4, 4)
								assert isinstance(outputs[0],    np.ndarray	)
								assert outputs[0].shape == (1, 3, 4, 4)

								# test with a non-tensor attribute
								lowerCamelCase__						:						Optional[Any]						      =CustomOutput({'''images''': [PIL.Image.new('''RGB''',    (4, 4)	)]}	)

								# check every way of getting the attribute
								assert isinstance(outputs.images,    lowerCamelCase	)
								assert isinstance(outputs.images[0],    PIL.Image.Image	)
								assert isinstance(outputs['''images'''],    lowerCamelCase	)
								assert isinstance(outputs['''images'''][0],    PIL.Image.Image	)
								assert isinstance(outputs[0],    lowerCamelCase	)
								assert isinstance(outputs[0][0],    PIL.Image.Image	)









"""simple docstring"""






from typing import TYPE_CHECKING

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


_lowercase					:					str 		=		{
    "configuration_openai": ["OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "OpenAIGPTConfig"],
    "tokenization_openai": ["OpenAIGPTTokenizer"],
}

try:
		if not is_tokenizers_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase					:					List[Any] 		=		["OpenAIGPTTokenizerFast"]

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase					:					Union[str, Any] 		=		[
		    "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:
		_lowercase					:					Optional[Any] 		=		[
		    "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

		_lowercase					:					Dict 		=		_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)




