





'''simple docstring'''

from typing import TYPE_CHECKING

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


lowercase__		:    List[Any] =       {'configuration_levit': ['LEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LevitConfig', 'LevitOnnxConfig']}

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowercase__		:    Optional[int] =       ['LevitFeatureExtractor']
   lowercase__		:    Union[str, Any] =       ['LevitImageProcessor']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowercase__		:    Dict =       [
       'LEVIT_PRETRAINED_MODEL_ARCHIVE_LIST',
       'LevitForImageClassification',
       'LevitForImageClassificationWithTeacher',
       'LevitModel',
       'LevitPreTrainedModel',
   ]


if TYPE_CHECKING:
   from .configuration_levit import LEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP, LevitConfig, LevitOnnxConfig

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .feature_extraction_levit import LevitFeatureExtractor
      from .image_processing_levit import LevitImageProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_levit import (
          LEVIT_PRETRAINED_MODEL_ARCHIVE_LIST,
          LevitForImageClassification,
          LevitForImageClassificationWithTeacher,
          LevitModel,
          LevitPreTrainedModel,
      )
else:
   import sys

   lowercase__		:    Union[str, 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  )



