




import unittest

import numpy as np

from transformers import BlipTextConfig
from transformers.testing_utils import require_torch, slow, torch_device
from transformers.utils import is_torch_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask


if is_torch_available():
      import torch

      from transformers import BlipTextModel
      from transformers.models.blip.modeling_blip import BLIP_PRETRAINED_MODEL_ARCHIVE_LIST






class 			A			:
     """simple docstring"""

     def __init__(    self  :   Union[str, Any]	,  A__  :   Optional[Any]	,  A__  :   str=1_2	,  A__  :   Any=7	,  A__  :   List[str]=True	,  A__  :   Union[str, Any]=True	,  A__  :   Optional[int]=True	,  A__  :   int=9_9	,  A__  :   List[Any]=3_2	,  A__  :   int=3_2	,  A__  :   str=5	,  A__  :   int=4	,  A__  :   Optional[Any]=3_7	,  A__  :   Union[str, Any]=0.1	,  A__  :   List[Any]=0.1	,  A__  :   Tuple=5_1_2	,  A__  :   Dict=0.02	,  A__  :   Tuple=0	,  A__  :   List[Any]=None	,  )				->       int:
           lowerCamelCase__        =				parent
           lowerCamelCase__        =				batch_size
           lowerCamelCase__        =				seq_length
           lowerCamelCase__        =				is_training
           lowerCamelCase__        =				use_input_mask
           lowerCamelCase__        =				use_labels
           lowerCamelCase__        =				vocab_size
           lowerCamelCase__        =				hidden_size
           lowerCamelCase__        =				projection_dim
           lowerCamelCase__        =				num_hidden_layers
           lowerCamelCase__        =				num_attention_heads
           lowerCamelCase__        =				intermediate_size
           lowerCamelCase__        =				dropout
           lowerCamelCase__        =				attention_dropout
           lowerCamelCase__        =				max_position_embeddings
           lowerCamelCase__        =				initializer_range
           lowerCamelCase__        =				scope
           lowerCamelCase__        =				bos_token_id




     def  __snake_case   (    self  :   List[str]			)				->       int:
           lowerCamelCase__        =				ids_tensor([self.batch_size, self.seq_length]	,  self.vocab_size			)

           lowerCamelCase__        =				None
           if self.use_input_mask:
                 lowerCamelCase__        =				random_attention_mask([self.batch_size, self.seq_length]			)

           if input_mask is not None:
                 lowerCamelCase__  ,		lowerCamelCase__        =				input_mask.shape
                 lowerCamelCase__        =				np.random.randint(1	,  seq_length - 1	,  size=(batch_size,)			)
                 for batch_idx, start_index in enumerate(A__			):
                       lowerCamelCase__        =				1
                       lowerCamelCase__        =				0

           lowerCamelCase__        =				self.get_config()

           return config, input_ids, input_mask




     def  __snake_case   (    self  :   Dict			)				->       str:
           return BlipTextConfig(
               vocab_size=self.vocab_size	,  hidden_size=self.hidden_size	,  projection_dim=self.projection_dim	,  num_hidden_layers=self.num_hidden_layers	,  num_attention_heads=self.num_attention_heads	,  intermediate_size=self.intermediate_size	,  dropout=self.dropout	,  attention_dropout=self.attention_dropout	,  max_position_embeddings=self.max_position_embeddings	,  initializer_range=self.initializer_range	,  bos_token_id=self.bos_token_id	,  )




     def  __snake_case   (    self  :   int	,  A__  :   int	,  A__  :   Tuple	,  A__  :   Any			)				->       List[Any]:
           lowerCamelCase__        =				BlipTextModel(config=A__			)
           model.to(A__			)
           model.eval()
           with torch.no_grad():
                 lowerCamelCase__        =				model(A__	,  attention_mask=A__			)
                 lowerCamelCase__        =				model(A__			)
           self.parent.assertEqual(result.last_hidden_state.shape	,  (self.batch_size, self.seq_length, self.hidden_size)			)
           self.parent.assertEqual(result.pooler_output.shape	,  (self.batch_size, self.hidden_size)			)




     def  __snake_case   (    self  :   str			)				->       Dict:
           lowerCamelCase__        =				self.prepare_config_and_inputs()
           lowerCamelCase__  ,		lowerCamelCase__  ,		lowerCamelCase__        =				config_and_inputs
           lowerCamelCase__        =				{'input_ids': input_ids, 'attention_mask': input_mask}
           return config, inputs_dict






@require_torch
class 			A			(		_lowerCAmelCase			,						unittest.TestCase		):
     """simple docstring"""

     _snake_case:	List[Any]     =(BlipTextModel,) if is_torch_available() else ()
     _snake_case:	Any     =False
     _snake_case:	Dict     =False
     _snake_case:	int     =False




     def  __snake_case   (    self  :   Dict			)				->       Union[str, Any]:
           lowerCamelCase__        =				BlipTextModelTester(self			)
           lowerCamelCase__        =				ConfigTester(self	,  config_class=A__	,  hidden_size=3_7			)




     def  __snake_case   (    self  :   Any			)				->       Any:
           self.config_tester.run_common_tests()




     def  __snake_case   (    self  :   List[Any]			)				->       Tuple:
           lowerCamelCase__        =				self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_model(*A__			)




     def  __snake_case   (    self  :   int			)				->       int:
           pass




     def  __snake_case   (    self  :   List[Any]			)				->       Tuple:
           pass




     @unittest.skip(reason='Blip does not use inputs_embeds'			)
     def  __snake_case   (    self  :   int			)				->       Optional[int]:
           pass




     @unittest.skip(reason='BlipTextModel has no base class and is not available in MODEL_MAPPING'			)
     def  __snake_case   (    self  :   List[Any]			)				->       List[Any]:
           pass




     @unittest.skip(reason='BlipTextModel has no base class and is not available in MODEL_MAPPING'			)
     def  __snake_case   (    self  :   List[Any]			)				->       Dict:
           pass




     @slow
     def  __snake_case   (    self  :   str			)				->       Optional[Any]:
           for model_name in BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                 lowerCamelCase__        =				BlipTextModel.from_pretrained(A__			)
                 self.assertIsNotNone(A__			)




     def  __snake_case   (    self  :   Optional[int]			)				->       Optional[int]:
           super().test_pt_tf_model_equivalence(allow_missing_keys=A__			)





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)