



'''simple docstring'''
import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
					import torch

if is_vision_available():
					from PIL import Image

					from transformers import EfficientNetImageProcessor






class 							lowercase__			(							unittest.TestCase     ):





	def __init__(				self      :       List[Any]				,lowerCamelCase__      :       str				,lowerCamelCase__      :       Optional[int]=13				,lowerCamelCase__      :       int=3				,lowerCamelCase__      :       Any=18				,lowerCamelCase__      :       Tuple=30				,lowerCamelCase__      :       int=400				,lowerCamelCase__      :       Dict=True				,lowerCamelCase__      :       List[Any]=None				,lowerCamelCase__      :       Tuple=True				,lowerCamelCase__      :       str=[0.5, 0.5, 0.5]				,lowerCamelCase__      :       List[str]=[0.5, 0.5, 0.5]				,):







							'''simple docstring'''
							_UpperCamelCase      :	Optional[int]				       =     size if size is not None else {'height': 18, 'width': 18}
							_UpperCamelCase      :	Any				       =     parent
							_UpperCamelCase      :	Any				       =     batch_size
							_UpperCamelCase      :	List[Any]				       =     num_channels
							_UpperCamelCase      :	Optional[Any]				       =     image_size
							_UpperCamelCase      :	Optional[Any]				       =     min_resolution
							_UpperCamelCase      :	Any				       =     max_resolution
							_UpperCamelCase      :	Union[str, Any]				       =     do_resize
							_UpperCamelCase      :	str				       =     size
							_UpperCamelCase      :	Optional[Any]				       =     do_normalize
							_UpperCamelCase      :	str				       =     image_mean
							_UpperCamelCase      :	List[Any]				       =     image_std





	def 			UpperCamelCase_						(				self      :       int				):







							'''simple docstring'''
							return {
							    "image_mean": self.image_mean,
							    "image_std": self.image_std,
							    "do_normalize": self.do_normalize,
							    "do_resize": self.do_resize,
							    "size": self.size,
							}






@require_torch
@require_vision
class 							lowercase__			(							lowercase		,      unittest.TestCase     ):
	lowercase__						       =    EfficientNetImageProcessor if is_vision_available() else None





	def 			UpperCamelCase_						(				self      :       List[str]				):







							'''simple docstring'''
							_UpperCamelCase      :	List[Any]				       =     EfficientNetImageProcessorTester(self				)





	@property
	def 			UpperCamelCase_						(				self      :       List[str]				):







							'''simple docstring'''
							return self.image_processor_tester.prepare_image_processor_dict()





	def 			UpperCamelCase_						(				self      :       List[Any]				):







							'''simple docstring'''
							_UpperCamelCase      :	Tuple				       =     self.image_processing_class(**self.image_processor_dict				)
							self.assertTrue(hasattr(lowerCamelCase__				,'image_mean'				)				)
							self.assertTrue(hasattr(lowerCamelCase__				,'image_std'				)				)
							self.assertTrue(hasattr(lowerCamelCase__				,'do_normalize'				)				)
							self.assertTrue(hasattr(lowerCamelCase__				,'do_resize'				)				)
							self.assertTrue(hasattr(lowerCamelCase__				,'size'				)				)





	def 			UpperCamelCase_						(				self      :       int				):







							'''simple docstring'''
							_UpperCamelCase      :	str				       =     self.image_processing_class.from_dict(self.image_processor_dict				)
							self.assertEqual(image_processor.size				,{'height': 18, 'width': 18}				)

							_UpperCamelCase      :	Union[str, Any]				       =     self.image_processing_class.from_dict(self.image_processor_dict				,size=42				)
							self.assertEqual(image_processor.size				,{'height': 42, 'width': 42}				)





	def 			UpperCamelCase_						(				self      :       List[Any]				):







							'''simple docstring'''
							# Initialize image_processing
							_UpperCamelCase      :	Union[str, Any]				       =     self.image_processing_class(**self.image_processor_dict				)
							# create random PIL images
							_UpperCamelCase      :	Optional[int]				       =     prepare_image_inputs(self.image_processor_tester				,equal_resolution=lowerCamelCase__				)
							for image in image_inputs:
													self.assertIsInstance(lowerCamelCase__				,Image.Image				)

							# Test not batched input
							_UpperCamelCase      :	Optional[int]				       =     image_processing(image_inputs[0]				,return_tensors='pt'				).pixel_values
							self.assertEqual(
							    encoded_images.shape				,(
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.size['height'],
							        self.image_processor_tester.size['width'],
							    )				,)

							# Test batched
							_UpperCamelCase      :	Optional[int]				       =     image_processing(lowerCamelCase__				,return_tensors='pt'				).pixel_values
							self.assertEqual(
							    encoded_images.shape				,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.size['height'],
							        self.image_processor_tester.size['width'],
							    )				,)





	def 			UpperCamelCase_						(				self      :       Optional[int]				):







							'''simple docstring'''
							# Initialize image_processing
							_UpperCamelCase      :	int				       =     self.image_processing_class(**self.image_processor_dict				)
							# create random numpy tensors
							_UpperCamelCase      :	Any				       =     prepare_image_inputs(self.image_processor_tester				,equal_resolution=lowerCamelCase__				,numpify=lowerCamelCase__				)
							for image in image_inputs:
													self.assertIsInstance(lowerCamelCase__				,np.ndarray				)

							# Test not batched input
							_UpperCamelCase      :	List[str]				       =     image_processing(image_inputs[0]				,return_tensors='pt'				).pixel_values
							self.assertEqual(
							    encoded_images.shape				,(
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.size['height'],
							        self.image_processor_tester.size['width'],
							    )				,)

							# Test batched
							_UpperCamelCase      :	List[Any]				       =     image_processing(lowerCamelCase__				,return_tensors='pt'				).pixel_values
							self.assertEqual(
							    encoded_images.shape				,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.size['height'],
							        self.image_processor_tester.size['width'],
							    )				,)





	def 			UpperCamelCase_						(				self      :       List[str]				):







							'''simple docstring'''
							# Initialize image_processing
							_UpperCamelCase      :	Tuple				       =     self.image_processing_class(**self.image_processor_dict				)
							# create random PyTorch tensors
							_UpperCamelCase      :	int				       =     prepare_image_inputs(self.image_processor_tester				,equal_resolution=lowerCamelCase__				,torchify=lowerCamelCase__				)
							for image in image_inputs:
													self.assertIsInstance(lowerCamelCase__				,torch.Tensor				)

							# Test not batched input
							_UpperCamelCase      :	Optional[Any]				       =     image_processing(image_inputs[0]				,return_tensors='pt'				).pixel_values
							self.assertEqual(
							    encoded_images.shape				,(
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.size['height'],
							        self.image_processor_tester.size['width'],
							    )				,)

							# Test batched
							_UpperCamelCase      :	List[Any]				       =     image_processing(lowerCamelCase__				,return_tensors='pt'				).pixel_values
							self.assertEqual(
							    encoded_images.shape				,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.size['height'],
							        self.image_processor_tester.size['width'],
							    )				,)







'''simple docstring'''
from __future__ import annotations

from queue import Queue






class 							lowercase__			:





	def __init__(				self      :       int				):







							'''simple docstring'''
							_UpperCamelCase      :	dict[int, list[int]]				       =     {}





	def 			UpperCamelCase_						(				self      :       int				):







							'''simple docstring'''
							for i in self.vertices:
													print(lowerCamelCase__				,' : '				,' -> '.join([str(lowerCamelCase__				) for j in self.vertices[i]]				)				)





	def 			UpperCamelCase_						(				self      :       Optional[Any]				,lowerCamelCase__      :       int				,lowerCamelCase__      :       int				):







							'''simple docstring'''
							if from_vertex in self.vertices:
													self.vertices[from_vertex].append(lowerCamelCase__				)
							else:
													_UpperCamelCase      :	Any				       =     [to_vertex]





	def 			UpperCamelCase_						(				self      :       int				,lowerCamelCase__      :       int				):







							'''simple docstring'''
							_UpperCamelCase      :	Dict				       =     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(lowerCamelCase__				)
							queue.put(lowerCamelCase__				)

							while not queue.empty():
													_UpperCamelCase      :	Optional[Any]				       =     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(lowerCamelCase__				)
																									visited.add(lowerCamelCase__				)
							return visited


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

					testmod(verbose=True)

					snake_case_				:			int						 =						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]


