


from __future__ import annotations

import unittest

from transformers import AlbertConfig, is_tf_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
			import tensorflow as tf

			from transformers import TF_MODEL_FOR_PRETRAINING_MAPPING
			from transformers.models.albert.modeling_tf_albert import (
			    TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
			    TFAlbertForMaskedLM,
			    TFAlbertForMultipleChoice,
			    TFAlbertForPreTraining,
			    TFAlbertForQuestionAnswering,
			    TFAlbertForSequenceClassification,
			    TFAlbertForTokenClassification,
			    TFAlbertModel,
			)

class 			lowerCamelCase_					:





							def __init__(							self			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE=13			,       _SCREAMING_SNAKE_CASE=7			,       _SCREAMING_SNAKE_CASE=True			,       _SCREAMING_SNAKE_CASE=True			,       _SCREAMING_SNAKE_CASE=True			,       _SCREAMING_SNAKE_CASE=True			,       _SCREAMING_SNAKE_CASE=99			,       _SCREAMING_SNAKE_CASE=16			,       _SCREAMING_SNAKE_CASE=32			,       _SCREAMING_SNAKE_CASE=2			,       _SCREAMING_SNAKE_CASE=4			,       _SCREAMING_SNAKE_CASE=37			,       _SCREAMING_SNAKE_CASE="gelu"			,       _SCREAMING_SNAKE_CASE=0.1			,       _SCREAMING_SNAKE_CASE=0.1			,       _SCREAMING_SNAKE_CASE=512			,       _SCREAMING_SNAKE_CASE=16			,       _SCREAMING_SNAKE_CASE=2			,       _SCREAMING_SNAKE_CASE=0.0_2			,       _SCREAMING_SNAKE_CASE=3			,       _SCREAMING_SNAKE_CASE=4			,       _SCREAMING_SNAKE_CASE=None			,       ):
								a_     			=   parent
								a_     			=   13
								a_     			=   7
								a_     			=   True
								a_     			=   True
								a_     			=   True
								a_     			=   True
								a_     			=   99
								a_     			=   16
								a_     			=   32
								a_     			=   2
								a_     			=   4
								a_     			=   37
								a_     			=   """gelu"""
								a_     			=   0.1
								a_     			=   0.1
								a_     			=   512
								a_     			=   16
								a_     			=   2
								a_     			=   0.0_2
								a_     			=   3
								a_     			=   4
								a_     			=   None





							def   __magic_name__      (							self    ):
								a_     			=   ids_tensor([self.batch_size, self.seq_length]			,       self.vocab_size    )

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

								a_     			=   None
								if self.use_token_type_ids:
									a_     			=   ids_tensor([self.batch_size, self.seq_length]			,       self.type_vocab_size    )

								a_     			=   None
								a_     			=   None
								a_     			=   None
								if self.use_labels:
									a_     			=   ids_tensor([self.batch_size]			,       self.type_sequence_label_size    )
									a_     			=   ids_tensor([self.batch_size, self.seq_length]			,       self.num_labels    )
									a_     			=   ids_tensor([self.batch_size]			,       self.num_choices    )

								a_     			=   AlbertConfig(
								    vocab_size=self.vocab_size			,       hidden_size=self.hidden_size			,       embedding_size=self.embedding_size			,       num_hidden_layers=self.num_hidden_layers			,       num_attention_heads=self.num_attention_heads			,       intermediate_size=self.intermediate_size			,       hidden_act=self.hidden_act			,       hidden_dropout_prob=self.hidden_dropout_prob			,       attention_probs_dropout_prob=self.attention_probs_dropout_prob			,       max_position_embeddings=self.max_position_embeddings			,       type_vocab_size=self.type_vocab_size			,       initializer_range=self.initializer_range			,       )

								return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels





							def   __magic_name__      (							self			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE    ):
								a_     			=   TFAlbertModel(config=_SCREAMING_SNAKE_CASE    )
								# inputs = {'input_ids': input_ids,
								#           'attention_mask': input_mask,
								#           'token_type_ids': token_type_ids}
								# sequence_output, pooled_output = model(**inputs)
								a_     			=   {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
								a_     			=   model(_SCREAMING_SNAKE_CASE    )

								a_     			=   [input_ids, input_mask]
								a_     			=   model(_SCREAMING_SNAKE_CASE    )

								a_     			=   model(_SCREAMING_SNAKE_CASE    )

								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   __magic_name__      (							self			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE    ):
								a_     			=   self.num_labels
								a_     			=   TFAlbertForPreTraining(config=_SCREAMING_SNAKE_CASE    )
								a_     			=   {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
								a_     			=   model(_SCREAMING_SNAKE_CASE    )
								self.parent.assertEqual(result.prediction_logits.shape			,       (self.batch_size, self.seq_length, self.vocab_size)    )
								self.parent.assertEqual(result.sop_logits.shape			,       (self.batch_size, self.num_labels)    )





							def   __magic_name__      (							self			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE    ):
								a_     			=   TFAlbertForMaskedLM(config=_SCREAMING_SNAKE_CASE    )
								a_     			=   {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
								a_     			=   model(_SCREAMING_SNAKE_CASE    )
								self.parent.assertEqual(result.logits.shape			,       (self.batch_size, self.seq_length, self.vocab_size)    )





							def   __magic_name__      (							self			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE    ):
								a_     			=   self.num_labels
								a_     			=   TFAlbertForSequenceClassification(config=_SCREAMING_SNAKE_CASE    )
								a_     			=   {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
								a_     			=   model(_SCREAMING_SNAKE_CASE    )
								self.parent.assertEqual(result.logits.shape			,       (self.batch_size, self.num_labels)    )





							def   __magic_name__      (							self			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE    ):
								a_     			=   TFAlbertForQuestionAnswering(config=_SCREAMING_SNAKE_CASE    )
								a_     			=   {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
								a_     			=   model(_SCREAMING_SNAKE_CASE    )
								self.parent.assertEqual(result.start_logits.shape			,       (self.batch_size, self.seq_length)    )
								self.parent.assertEqual(result.end_logits.shape			,       (self.batch_size, self.seq_length)    )





							def   __magic_name__      (							self			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE    ):
								a_     			=   self.num_choices
								a_     			=   TFAlbertForMultipleChoice(config=_SCREAMING_SNAKE_CASE    )
								a_     			=   tf.tile(tf.expand_dims(_SCREAMING_SNAKE_CASE			,       1    )			,       (1, self.num_choices, 1)    )
								a_     			=   tf.tile(tf.expand_dims(_SCREAMING_SNAKE_CASE			,       1    )			,       (1, self.num_choices, 1)    )
								a_     			=   tf.tile(tf.expand_dims(_SCREAMING_SNAKE_CASE			,       1    )			,       (1, self.num_choices, 1)    )
								a_     			=   {
								    """input_ids""": multiple_choice_inputs_ids,
								    """attention_mask""": multiple_choice_input_mask,
								    """token_type_ids""": multiple_choice_token_type_ids,
								}
								a_     			=   model(_SCREAMING_SNAKE_CASE    )
								self.parent.assertListEqual(list(result["""logits"""].shape    )			,       [self.batch_size, self.num_choices]    )





							def   __magic_name__      (							self			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE    ):
								a_     			=   self.num_labels
								a_     			=   TFAlbertForTokenClassification(config=_SCREAMING_SNAKE_CASE    )
								a_     			=   {
								    """input_ids""": input_ids,
								    """attention_mask""": input_mask,
								    """token_type_ids""": token_type_ids,
								}
								a_     			=   model(_SCREAMING_SNAKE_CASE    )
								self.parent.assertListEqual(list(result["""logits"""].shape    )			,       [self.batch_size, self.seq_length, self.num_labels]    )





							def   __magic_name__      (							self    ):
								a_     			=   self.prepare_config_and_inputs()
								(
								    (
								    a_
								)			, (
								    a_
								)			, (
								    a_
								)			, (
								    a_
								)			, (
								    a_
								)			, (
								    a_
								)			, (
								    a_
								)			, 
								)     			=   config_and_inputs
								a_     			=   {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
								return config, inputs_dict







@require_tf
class 			lowerCamelCase_					(    _SCREAMING_SNAKE_CASE   ,		_SCREAMING_SNAKE_CASE   ,		unittest.TestCase    ):
							_lowerCamelCase				: str       =					(
							    (
							        TFAlbertModel,
							        TFAlbertForPreTraining,
							        TFAlbertForMaskedLM,
							        TFAlbertForSequenceClassification,
							        TFAlbertForQuestionAnswering,
							        TFAlbertForTokenClassification,
							        TFAlbertForMultipleChoice,
							    )
							    if is_tf_available()
							    else ()
							)
							_lowerCamelCase				: int       =					(
							    {
							        """feature-extraction""": TFAlbertModel,
							        """fill-mask""": TFAlbertForMaskedLM,
							        """question-answering""": TFAlbertForQuestionAnswering,
							        """text-classification""": TFAlbertForSequenceClassification,
							        """token-classification""": TFAlbertForTokenClassification,
							        """zero-shot""": TFAlbertForSequenceClassification,
							    }
							    if is_tf_available()
							    else {}
							)
							_lowerCamelCase				: str       =					False
							_lowerCamelCase				: Dict       =					False





							def   __magic_name__      (							self			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE=False    ):
								a_     			=   super()._prepare_for_class(_SCREAMING_SNAKE_CASE			,       _SCREAMING_SNAKE_CASE			,       return_labels=_SCREAMING_SNAKE_CASE    )

								if return_labels:
									if model_class in get_values(_SCREAMING_SNAKE_CASE    ):
										a_     			=   tf.zeros(self.model_tester.batch_size			,       dtype=tf.intaa    )

								return inputs_dict





							def   __magic_name__      (							self    ):
								a_     			=   TFAlbertModelTester(self    )
								a_     			=   ConfigTester(self			,       config_class=_SCREAMING_SNAKE_CASE			,       hidden_size=37    )





							def   __magic_name__      (							self    ):
								self.config_tester.run_common_tests()





							def   __magic_name__      (							self    ):
								a_     			=   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_albert_model(*_SCREAMING_SNAKE_CASE    )





							def   __magic_name__      (							self    ):
								a_     			=   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_albert_for_pretraining(*_SCREAMING_SNAKE_CASE    )





							def   __magic_name__      (							self    ):
								a_     			=   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_albert_for_masked_lm(*_SCREAMING_SNAKE_CASE    )





							def   __magic_name__      (							self    ):
								a_     			=   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_albert_for_multiple_choice(*_SCREAMING_SNAKE_CASE    )





							def   __magic_name__      (							self    ):
								a_     			=   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_albert_for_sequence_classification(*_SCREAMING_SNAKE_CASE    )





							def   __magic_name__      (							self    ):
								a_     			=   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_albert_for_question_answering(*_SCREAMING_SNAKE_CASE    )





							@slow
							def   __magic_name__      (							self    ):
								for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									a_     			=   TFAlbertModel.from_pretrained(_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )







@require_tf
class 			lowerCamelCase_					(    unittest.TestCase    ):





							@slow
							def   __magic_name__      (							self    ):
								a_     			=   TFAlbertForPreTraining.from_pretrained("""albert-base-v2"""    )
								a_     			=   tf.constant([[0, 1, 2, 3, 4, 5]]    )
								a_     			=   model(_SCREAMING_SNAKE_CASE    )[0]

								a_     			=   [1, 6, 3_0000]
								self.assertEqual(output.shape			,       _SCREAMING_SNAKE_CASE    )

								a_     			=   tf.constant(
								    [
								        [
								            [4.5_9_5_6_6_8, 0.7_4_4_6_2_7_5_4, -1.8_1_8_1_4_7],
								            [4.5_9_5_4_3_4_7, 0.7_4_5_4_1_8_4, -1.8_1_8_8_2_5_8],
								            [4.5_9_5_4_9_0_5, 0.7_4_4_8_2_3_5, -1.8_1_8_2_3_1_6],
								        ]
								    ]    )
								tf.debugging.assert_near(output[:, :3, :3]			,       _SCREAMING_SNAKE_CASE			,       atol=1E-4    )



def 			__SCREAMING_SNAKE_CASE		(		UpperCamelCase		:      int     ,					UpperCamelCase		:      list[tuple[int, int, int]]	)     ->	list[tuple[int, int, int]]:



	"""simple docstring"""






	a_     			=   sorted(UpperCamelCase     ,					key=lambda UpperCamelCase	: edge[2]	)

	a_     			=   list(range(UpperCamelCase	)	)

	def find_parent(UpperCamelCase		:      Any	):
		if i != parent[i]:
			a_     			=   find_parent(parent[i]	)
		return parent[i]

	a_     			=   0
	a_     			=   []

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

	return minimum_spanning_tree


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

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

			kruskal(num_nodes, edges)