





'''simple docstring'''

from typing import TYPE_CHECKING

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


lowercase__		:    Dict =       {
    '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__		:    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:
   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__		:    Optional[Any] =       _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)










'''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        __lowerCAmelCase  (					__magic_name__				):






       """simple docstring"""
       _snake_case			:  Union[List[PIL.Image.Image], np.ndarray]

class        __lowerCAmelCase  (					unittest.TestCase				):






       """simple docstring"""





       def snake_case__		(							self     :	Any  )					->  Any:

            '''simple docstring'''




            _UpperCamelCase       					= 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
            _UpperCamelCase       					= 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     :	List[str]  )					->  Union[str, Any]:

            '''simple docstring'''




            _UpperCamelCase       					= 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
            _UpperCamelCase       					= 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  )



