
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 	UpperCamelCase__       (  UpperCAmelCase__):

						'''simple docstring'''



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


class 	UpperCamelCase__       (  unittest.TestCase):

						'''simple docstring'''



						def    A__       (  self	)  ->Union[str, Any]:
									UpperCAmelCase__		:Tuple 		=    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__		:Dict 		=    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    A__       (  self	)  ->Optional[int]:
									# test output reinitialization with a `dict` for compatibility with `accelerate`
									UpperCAmelCase__		: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
									UpperCAmelCase__		:Optional[Any] 		=    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	)







from __future__ import annotations

from queue import Queue


class 	UpperCamelCase__       :

						'''simple docstring'''



						def __init__(  self	)  ->None:
									UpperCAmelCase__		:dict[int, list[int]] 		=    {}


						def    A__       (  self	)  ->None:
									for i in self.vertices:
												print(A  , ' : '  , ' -> '.join([str(A	) for j in self.vertices[i]]	)	)


						def    A__       (  self  , A  , A	)  ->None:
									if from_vertex in self.vertices:
												self.vertices[from_vertex].append(A	)
									else:
												UpperCAmelCase__		:Union[str, Any] 		=    [to_vertex]


						def    A__       (  self  , A	)  ->set[int]:
									UpperCAmelCase__		:str 		=    set()

									# create a first in first out queue to store all the vertices for BFS
									UpperCAmelCase__		:Queue 		=    Queue()

									# mark the source node as visited and enqueue it
									visited.add(A	)
									queue.put(A	)

									while not queue.empty():
												UpperCAmelCase__		:List[str] 		=    queue.get()

												# loop through all adjacent vertex and enqueue it if not yet visited
												for adjacent_vertex in self.vertices[vertex]:
															if adjacent_vertex not in visited:
																		queue.put(A	)
																		visited.add(A	)
									return visited


if __name__ == "__main__":
						from doctest import testmod

						testmod(verbose=True)

						__snake_case					:							Any           =							Graph()
						g.add_edge(0, 1)
						g.add_edge(0, 2)
						g.add_edge(1, 2)
						g.add_edge(2, 0)
						g.add_edge(2, 3)
						g.add_edge(3, 3)

						g.print_graph()
						# 0  :  1 -> 2
						# 1  :  2
						# 2  :  0 -> 3
						# 3  :  3

						assert sorted(g.bfs(2)) == [0, 1, 2, 3]





