




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 			A			(		_lowerCAmelCase			,						_lowerCAmelCase			,						unittest.TestCase		):
     """simple docstring"""

     _snake_case:	str     =IFSuperResolutionPipeline
     _snake_case:	List[Any]     =TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"width", "height"}
     _snake_case:	Optional[Any]     =TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
     _snake_case:	int     =PipelineTesterMixin.required_optional_params - {"latents"}




     def  __snake_case   (    self  :   List[Any]			)				->       List[Any]:
           return self._get_superresolution_dummy_components()




     def  __snake_case   (    self  :   Dict	,  A__  :   Union[str, Any]	,  A__  :   Optional[int]=0			)				->       int:
           if str(A__			).startswith('mps'			):
                 lowerCamelCase__        =				torch.manual_seed(A__			)
           else:
                 lowerCamelCase__        =				torch.Generator(device=A__			).manual_seed(A__			)

           lowerCamelCase__        =				floats_tensor((1, 3, 3_2, 3_2)	,  rng=random.Random(A__			)			).to(A__			)

           lowerCamelCase__        =				{
               '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  __snake_case   (    self  :   Dict			)				->       Optional[int]:
           self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3			)




     def  __snake_case   (    self  :   Optional[int]			)				->       Tuple:
           self._test_save_load_optional_components()




     @unittest.skipIf(torch_device != 'cuda'	,  reason='float16 requires CUDA'			)
     def  __snake_case   (    self  :   Optional[int]			)				->       Dict:
           # 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  __snake_case   (    self  :   List[str]			)				->       Tuple:
           self._test_attention_slicing_forward_pass(expected_max_diff=1E-2			)




     def  __snake_case   (    self  :   Tuple			)				->       Optional[Any]:
           self._test_save_load_local()




     def  __snake_case   (    self  :   List[Any]			)				->       str:
           self._test_inference_batch_single_identical(
               expected_max_diff=1E-2	,  )





def 			lowerCAmelCase_			(  lowerCamelCase:       int     ,				lowerCamelCase:       list[tuple[int, int, int]]						)					->			list[tuple[int, int, int]]:


      '''simple docstring'''




      lowerCamelCase__        =				sorted(lowerCamelCase     ,				key=lambda lowerCamelCase						: edge[2]						)

      lowerCamelCase__        =				list(range(lowerCamelCase						)						)

      def find_parent(lowerCamelCase:       int						):
            if i != parent[i]:
                  lowerCamelCase__        =				find_parent(parent[i]						)
            return parent[i]

      lowerCamelCase__        =				0
      lowerCamelCase__        =				[]

      for edge in edges:
            lowerCamelCase__        =				find_parent(edge[0]						)
            lowerCamelCase__        =				find_parent(edge[1]						)
            if parent_a != parent_b:
                  minimum_spanning_tree_cost += edge[2]
                  minimum_spanning_tree.append(lowerCamelCase						)
                  lowerCamelCase__        =				parent_b

      return minimum_spanning_tree


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

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

      kruskal(num_nodes, edges)