





'''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 A_      (    _lowerCamelCase     ):
   lowerCAmelCase__       =				42





class A_      (    unittest.TestCase     ):




   def _lowerCAmelCase   (self			:Tuple				)->      Dict:
         __A      =       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
         __A      =       CustomOutput(images=[PIL.Image.new('''RGB'''					,     (4, 4)				)]				)

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






   def _lowerCAmelCase   (self			:Union[str, Any]				)->      str:
         # test output reinitialization with a `dict` for compatibility with `accelerate`
         __A      =       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
         __A      =       CustomOutput({'''images''': [PIL.Image.new('''RGB'''					,     (4, 4)				)]}				)

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












from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


snake_case__      :							Optional[int]									=  {'configuration_cvt': ['CVT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CvtConfig']}


try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       snake_case__      :							Union[str, Any]									=  [
           'CVT_PRETRAINED_MODEL_ARCHIVE_LIST',
           'CvtForImageClassification',
           'CvtModel',
           'CvtPreTrainedModel',
       ]

try:
       if not is_tf_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       snake_case__      :							List[str]									=  [
           'TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST',
           'TFCvtForImageClassification',
           'TFCvtModel',
           'TFCvtPreTrainedModel',
       ]

if TYPE_CHECKING:
       from .configuration_cvt import CVT_PRETRAINED_CONFIG_ARCHIVE_MAP, CvtConfig

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_cvt import (
                  CVT_PRETRAINED_MODEL_ARCHIVE_LIST,
                  CvtForImageClassification,
                  CvtModel,
                  CvtPreTrainedModel,
              )

       try:
              if not is_tf_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_tf_cvt import (
                  TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST,
                  TFCvtForImageClassification,
                  TFCvtModel,
                  TFCvtPreTrainedModel,
              )


else:
       import sys

       snake_case__      :							Dict									=  _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)





