




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		):
     """simple docstring"""

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






class 			A			(		unittest.TestCase		):
     """simple docstring"""

     def  __snake_case   (    self  :   Tuple			)				->       str:
           lowerCamelCase__        =				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__        =				CustomOutput(images=[PIL.Image.new('RGB'	,  (4, 4)			)]			)

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




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

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





import shutil

import requests

def 			lowerCAmelCase_			(  lowerCamelCase:       str     ,				lowerCamelCase:       bool = False     ,				lowerCamelCase:       str = "."						)					->			dict:


      '''simple docstring'''




      lowerCamelCase__        =				'https://api.nasa.gov/planetary/apod'
      return requests.get(lowerCamelCase     ,				params={'api_key': api_key}						).json()

def 			lowerCAmelCase_			(  lowerCamelCase:       str     ,				lowerCamelCase:       str = "."						)					->			dict:


      '''simple docstring'''




      lowerCamelCase__        =				get_apod_data(lowerCamelCase						)
      lowerCamelCase__        =				apod_data['url']
      lowerCamelCase__        =				img_url.split('/'						)[-1]
      lowerCamelCase__        =				requests.get(lowerCamelCase     ,				stream=lowerCamelCase						)

      with open(f"""{path}/{img_name}"""     ,				'wb+'						) as img_file:
            shutil.copyfileobj(response.raw     ,				lowerCamelCase						)
      del response
      return apod_data

def 			lowerCAmelCase_			(  lowerCamelCase:       str						)					->			dict:


      '''simple docstring'''




      lowerCamelCase__        =				'https://images-api.nasa.gov/search'
      return requests.get(lowerCamelCase     ,				params={'q': query}						).json()


if __name__ == "__main__":
      print(save_apod("""YOUR API KEY"""))
      __SCREAMING_SNAKE_CASE    :   Tuple       =get_archive_data("""apollo 2011""")["""collection"""]["""items"""]
      print(apollo_aaaa_items[0]["""data"""][0]["""description"""])