






'''simple docstring'''

import random
import unittest

import torch

from diffusers import IFSuperResolutionPipeline
from diffusers.utils import floats_tensor
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import skip_mps, torch_device

from ..pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin






@skip_mps
class 				__magic_name__  (						UpperCAmelCase_,    UpperCAmelCase_,    unittest.TestCase					):







	"""simple docstring"""



	SCREAMING_SNAKE_CASE_       :   List[Any]   =	IFSuperResolutionPipeline
	SCREAMING_SNAKE_CASE_       :   Optional[Any]   =	TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {'width', 'height'}
	SCREAMING_SNAKE_CASE_       :   Optional[int]   =	TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
	SCREAMING_SNAKE_CASE_       :   Tuple   =	PipelineTesterMixin.required_optional_params - {'latents'}
	def 							lowerCamelCase__		(				self							)    ->	str:
							return self._get_superresolution_dummy_components()
	def 							lowerCamelCase__		(				self	,   _lowercase	,   _lowercase=0							)    ->	List[Any]:
							if str(__SCREAMING_SNAKE_CASE							).startswith('mps'							):
													lowercase_   : Union[str, Any]   	=      torch.manual_seed(__SCREAMING_SNAKE_CASE							)
							else:
													lowercase_   : Union[str, Any]   	=      torch.Generator(device=__SCREAMING_SNAKE_CASE							).manual_seed(__SCREAMING_SNAKE_CASE							)

							lowercase_   : List[Any]   	=      floats_tensor((1, 3, 32, 32)	,   rng=random.Random(__SCREAMING_SNAKE_CASE							)							).to(__SCREAMING_SNAKE_CASE							)

							lowercase_   : Optional[Any]   	=      {
							    'prompt': 'A painting of a squirrel eating a burger',
							    'image': image,
							    'generator': generator,
							    'num_inference_steps': 2,
							    'output_type': 'numpy',
							}

							return inputs
	@unittest.skipIf(
	    torch_device != 'cuda' or not is_xformers_available()	,   reason='XFormers attention is only available with CUDA and `xformers` installed'	,   )
	def 							lowerCamelCase__		(				self							)    ->	Optional[int]:
							self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3							)
	def 							lowerCamelCase__		(				self							)    ->	List[Any]:
							self._test_save_load_optional_components()
	@unittest.skipIf(torch_device != 'cuda'	,   reason='float16 requires CUDA'							)
	def 							lowerCamelCase__		(				self							)    ->	int:
							# Due to non-determinism in save load of the hf-internal-testing/tiny-random-t5 text encoder
							super().test_save_load_floataa(expected_max_diff=1E-1							)
	def 							lowerCamelCase__		(				self							)    ->	int:
							self._test_attention_slicing_forward_pass(expected_max_diff=1E-2							)
	def 							lowerCamelCase__		(				self							)    ->	Union[str, Any]:
							self._test_save_load_local()







	def 							lowerCamelCase__		(				self							)    ->	str:
							self._test_inference_batch_single_identical(
							    expected_max_diff=1E-2	,   )


'''simple docstring'''

def        SCREAMING_SNAKE_CASE_  (	snake_case_				:	int   ,     snake_case_				:	list[tuple[int, int, int]]							)       ->	list[tuple[int, int, int]]:
 SCREAMING_SNAKE_CASE  :  List[Any]								=		sorted(snake_case_   ,     key=lambda snake_case_							: edge[2]							)

 SCREAMING_SNAKE_CASE  :  str								=		list(range(snake_case_							)							)

 def find_parent(snake_case_				:	Union[str, Any]							):
  if i != parent[i]:
   SCREAMING_SNAKE_CASE  :  int								=		find_parent(parent[i]							)
  return parent[i]

 SCREAMING_SNAKE_CASE  :  Union[str, Any]								=		0
 SCREAMING_SNAKE_CASE  :  Any								=		[]

 for edge in edges:
  SCREAMING_SNAKE_CASE  :  Dict								=		find_parent(edge[0]							)
  SCREAMING_SNAKE_CASE  :  Optional[int]								=		find_parent(edge[1]							)
  if parent_a != parent_b:
   minimum_spanning_tree_cost += edge[2]
   minimum_spanning_tree.append(snake_case_							)
   SCREAMING_SNAKE_CASE  :  Tuple								=		parent_b

 return minimum_spanning_tree


if __name__ == "__main__":  # pragma: no cover
   __UpperCAmelCase						,						__UpperCAmelCase												=   list(map(int, input().strip().split()))
   __UpperCAmelCase												=   []

   for _ in range(num_edges):
      __UpperCAmelCase						,						__UpperCAmelCase						,						__UpperCAmelCase												=   (int(x) for x in input().strip().split())
      edges.append((nodea, nodea, cost))

   kruskal(num_nodes, edges)


