






import collections
import inspect
import unittest
from typing import Dict, List, Tuple

from transformers import MaskFormerSwinConfig
from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device
from transformers.utils import is_torch_available

from ...test_backbone_common import BackboneTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
					import torch
					from torch import nn

					from transformers import MaskFormerSwinBackbone
					from transformers.models.maskformer import MaskFormerSwinModel
class    _SCREAMING_SNAKE_CASE							:


			'''simple docstring'''





			def __init__(   self							:						List[str] ,      lowercase							:						Optional[int] ,      lowercase							:						List[Any]=1_3 ,      lowercase							:						Dict=3_2 ,      lowercase							:						str=2 ,      lowercase							:						int=3 ,      lowercase							:						List[str]=1_6 ,      lowercase							:						List[Any]=[1, 2, 1] ,      lowercase							:						Optional[Any]=[2, 2, 4] ,      lowercase							:						Any=2 ,      lowercase							:						Optional[int]=2.0 ,      lowercase							:						Tuple=True ,      lowercase							:						Dict=0.0 ,      lowercase							:						Optional[Any]=0.0 ,      lowercase							:						Union[str, Any]=0.1 ,      lowercase							:						Optional[int]="gelu" ,      lowercase							:						int=False ,      lowercase							:						Dict=True ,      lowercase							:						List[str]=0.0_2 ,      lowercase							:						List[str]=1e-5 ,      lowercase							:						Optional[int]=True ,      lowercase							:						int=None ,      lowercase							:						Tuple=True ,      lowercase							:						str=1_0 ,      lowercase							:						List[Any]=8 ,      lowercase							:						Optional[int]=["stage1", "stage2", "stage3"] ,      lowercase							:						int=[1, 2, 3] ,      )							->    int:

									'''simple docstring'''







									UpperCamelCase__         = parent
									UpperCamelCase__         = batch_size
									UpperCamelCase__         = image_size
									UpperCamelCase__         = patch_size
									UpperCamelCase__         = num_channels
									UpperCamelCase__         = embed_dim
									UpperCamelCase__         = depths
									UpperCamelCase__         = num_heads
									UpperCamelCase__         = window_size
									UpperCamelCase__         = mlp_ratio
									UpperCamelCase__         = qkv_bias
									UpperCamelCase__         = hidden_dropout_prob
									UpperCamelCase__         = attention_probs_dropout_prob
									UpperCamelCase__         = drop_path_rate
									UpperCamelCase__         = hidden_act
									UpperCamelCase__         = use_absolute_embeddings
									UpperCamelCase__         = patch_norm
									UpperCamelCase__         = layer_norm_eps
									UpperCamelCase__         = initializer_range
									UpperCamelCase__         = is_training
									UpperCamelCase__         = scope
									UpperCamelCase__         = use_labels
									UpperCamelCase__         = type_sequence_label_size
									UpperCamelCase__         = encoder_stride
									UpperCamelCase__         = out_features
									UpperCamelCase__         = out_indices






			def 				A      (   self							:						List[Any]			)							->    str:

									'''simple docstring'''







									UpperCamelCase__         = floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]			)

									UpperCamelCase__         = None
									if self.use_labels:
															UpperCamelCase__         = ids_tensor([self.batch_size] ,      self.type_sequence_label_size			)

									UpperCamelCase__         = self.get_config()

									return config, pixel_values, labels






			def 				A      (   self							:						Optional[Any]			)							->    Tuple:

									'''simple docstring'''







									return MaskFormerSwinConfig(
									    image_size=self.image_size ,      patch_size=self.patch_size ,      num_channels=self.num_channels ,      embed_dim=self.embed_dim ,      depths=self.depths ,      num_heads=self.num_heads ,      window_size=self.window_size ,      mlp_ratio=self.mlp_ratio ,      qkv_bias=self.qkv_bias ,      hidden_dropout_prob=self.hidden_dropout_prob ,      attention_probs_dropout_prob=self.attention_probs_dropout_prob ,      drop_path_rate=self.drop_path_rate ,      hidden_act=self.hidden_act ,      use_absolute_embeddings=self.use_absolute_embeddings ,      path_norm=self.patch_norm ,      layer_norm_eps=self.layer_norm_eps ,      initializer_range=self.initializer_range ,      encoder_stride=self.encoder_stride ,      out_features=self.out_features ,      out_indices=self.out_indices ,      )






			def 				A      (   self							:						Optional[int] ,      lowercase							:						Dict ,      lowercase							:						Union[str, Any] ,      lowercase							:						Dict			)							->    Union[str, Any]:

									'''simple docstring'''







									UpperCamelCase__         = MaskFormerSwinModel(config=UpperCamelCase_			)
									model.to(UpperCamelCase_			)
									model.eval()
									UpperCamelCase__         = model(UpperCamelCase_			)

									UpperCamelCase__         = ((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths			) - 1))
									UpperCamelCase__         = int(config.embed_dim * 2 ** (len(config.depths			) - 1)			)

									self.parent.assertEqual(result.last_hidden_state.shape ,      (self.batch_size, expected_seq_len, expected_dim)			)






			def 				A      (   self							:						int ,      lowercase							:						Any ,      lowercase							:						List[str] ,      lowercase							:						List[str]			)							->    int:

									'''simple docstring'''







									UpperCamelCase__         = MaskFormerSwinBackbone(config=UpperCamelCase_			)
									model.to(UpperCamelCase_			)
									model.eval()
									UpperCamelCase__         = model(UpperCamelCase_			)

									# verify feature maps
									self.parent.assertEqual(len(result.feature_maps			) ,      len(config.out_features			)			)
									self.parent.assertListEqual(list(result.feature_maps[0].shape			) ,      [1_3, 1_6, 1_6, 1_6]			)

									# verify channels
									self.parent.assertEqual(len(model.channels			) ,      len(config.out_features			)			)
									self.parent.assertListEqual(model.channels ,      [1_6, 3_2, 6_4]			)

									# verify ValueError
									with self.parent.assertRaises(UpperCamelCase_			):
															UpperCamelCase__         = ["""stem"""]
															UpperCamelCase__         = MaskFormerSwinBackbone(config=UpperCamelCase_			)







			def 				A      (   self							:						Tuple			)							->    List[str]:

									'''simple docstring'''







									UpperCamelCase__         = self.prepare_config_and_inputs()
									UpperCamelCase__    ,   UpperCamelCase__    ,   UpperCamelCase__         = config_and_inputs
									UpperCamelCase__         = {"""pixel_values""": pixel_values}
									return config, inputs_dict
@require_torch
class    _SCREAMING_SNAKE_CASE							(		__lowerCamelCase       ,__lowerCamelCase       ,unittest.TestCase	):


			'''simple docstring'''





			__a							:							int					     =					(
			    (
			        MaskFormerSwinModel,
			        MaskFormerSwinBackbone,
			    )
			    if is_torch_available()
			    else ()
			)
			__a							:							List[str]					     =					{'feature-extraction': MaskFormerSwinModel} if is_torch_available() else {}
			__a							:							Tuple					     =					False
			__a							:							List[str]					     =					False
			__a							:							Union[str, Any]					     =					False
			__a							:							str					     =					False
			__a							:							str					     =					False






			def 				A      (   self							:						List[str]			)							->    Optional[int]:

									'''simple docstring'''







									UpperCamelCase__         = MaskFormerSwinModelTester(self			)
									UpperCamelCase__         = ConfigTester(self ,      config_class=UpperCamelCase_ ,      embed_dim=3_7			)






			@require_torch_multi_gpu
			@unittest.skip(
			    reason=(
			        """`MaskFormerSwinModel` outputs `hidden_states_spatial_dimensions` which doesn't work well with"""
			        """ `nn.DataParallel`"""
			    )			)
			def 				A      (   self							:						Optional[int]			)							->    str:

									'''simple docstring'''







									pass






			def 				A      (   self							:						Tuple			)							->    List[str]:

									'''simple docstring'''







									self.create_and_test_config_common_properties()
									self.config_tester.create_and_test_config_to_json_string()
									self.config_tester.create_and_test_config_to_json_file()
									self.config_tester.create_and_test_config_from_and_save_pretrained()
									self.config_tester.create_and_test_config_with_num_labels()
									self.config_tester.check_config_can_be_init_without_params()
									self.config_tester.check_config_arguments_init()






			def 				A      (   self							:						Any			)							->    Any:

									'''simple docstring'''







									return






			def 				A      (   self							:						str			)							->    List[str]:

									'''simple docstring'''







									UpperCamelCase__         = self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*UpperCamelCase_			)






			def 				A      (   self							:						Optional[int]			)							->    int:

									'''simple docstring'''







									UpperCamelCase__         = self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_backbone(*UpperCamelCase_			)






			@unittest.skip("""Swin does not use inputs_embeds"""			)
			def 				A      (   self							:						Any			)							->    Tuple:

									'''simple docstring'''







									pass






			@unittest.skip("""Swin does not support feedforward chunking"""			)
			def 				A      (   self							:						Optional[Any]			)							->    Tuple:

									'''simple docstring'''







									pass






			def 				A      (   self							:						Any			)							->    Tuple:

									'''simple docstring'''







									UpperCamelCase__    ,   UpperCamelCase__         = self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
															UpperCamelCase__         = model_class(UpperCamelCase_			)
															self.assertIsInstance(model.get_input_embeddings() ,      (nn.Module)			)
															UpperCamelCase__         = model.get_output_embeddings()
															self.assertTrue(x is None or isinstance(UpperCamelCase_ ,      nn.Linear			)			)






			def 				A      (   self							:						List[Any]			)							->    Optional[int]:

									'''simple docstring'''







									UpperCamelCase__    ,   UpperCamelCase__         = self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
															UpperCamelCase__         = model_class(UpperCamelCase_			)
															UpperCamelCase__         = inspect.signature(model.forward			)
															# signature.parameters is an OrderedDict => so arg_names order is deterministic
															UpperCamelCase__         = [*signature.parameters.keys()]

															UpperCamelCase__         = ["""pixel_values"""]
															self.assertListEqual(arg_names[:1] ,      UpperCamelCase_			)






			@unittest.skip(reason="""MaskFormerSwin is only used as backbone and doesn't support output_attentions"""			)
			def 				A      (   self							:						Tuple			)							->    Any:

									'''simple docstring'''







									pass






			@unittest.skip(reason="""MaskFormerSwin is only used as an internal backbone"""			)
			def 				A      (   self							:						List[Any]			)							->    int:

									'''simple docstring'''







									pass






			def 				A      (   self							:						List[str] ,      lowercase							:						Tuple ,      lowercase							:						Union[str, Any] ,      lowercase							:						Tuple ,      lowercase							:						Optional[int]			)							->    List[Any]:

									'''simple docstring'''







									UpperCamelCase__         = model_class(UpperCamelCase_			)
									model.to(UpperCamelCase_			)
									model.eval()

									with torch.no_grad():
															UpperCamelCase__         = model(**self._prepare_for_class(UpperCamelCase_ ,      UpperCamelCase_			)			)

									UpperCamelCase__         = outputs.hidden_states

									UpperCamelCase__         = getattr(
									    self.model_tester ,      """expected_num_hidden_layers""" ,      len(self.model_tester.depths			) + 1			)
									self.assertEqual(len(UpperCamelCase_			) ,      UpperCamelCase_			)

									# Swin has a different seq_length
									UpperCamelCase__         = (
									    config.patch_size
									    if isinstance(config.patch_size ,      collections.abc.Iterable			)
									    else (config.patch_size, config.patch_size)
									)

									UpperCamelCase__         = (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

									self.assertListEqual(
									    list(hidden_states[0].shape[-2:]			) ,      [num_patches, self.model_tester.embed_dim] ,      )






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

									'''simple docstring'''







									UpperCamelCase__    ,   UpperCamelCase__         = self.model_tester.prepare_config_and_inputs_for_common()

									UpperCamelCase__         = (
									    self.model_tester.image_size
									    if isinstance(self.model_tester.image_size ,      collections.abc.Iterable			)
									    else (self.model_tester.image_size, self.model_tester.image_size)
									)

									for model_class in self.all_model_classes:
															UpperCamelCase__         = True
															self.check_hidden_states_output(UpperCamelCase_ ,      UpperCamelCase_ ,      UpperCamelCase_ ,      UpperCamelCase_			)

															# check that output_hidden_states also work using config
															del inputs_dict["output_hidden_states"]
															UpperCamelCase__         = True

															self.check_hidden_states_output(UpperCamelCase_ ,      UpperCamelCase_ ,      UpperCamelCase_ ,      UpperCamelCase_			)






			def 				A      (   self							:						List[Any]			)							->    List[Any]:

									'''simple docstring'''







									UpperCamelCase__    ,   UpperCamelCase__         = self.model_tester.prepare_config_and_inputs_for_common()
									UpperCamelCase__         = 3

									UpperCamelCase__         = (
									    self.model_tester.image_size
									    if isinstance(self.model_tester.image_size ,      collections.abc.Iterable			)
									    else (self.model_tester.image_size, self.model_tester.image_size)
									)
									UpperCamelCase__         = (
									    config.patch_size
									    if isinstance(config.patch_size ,      collections.abc.Iterable			)
									    else (config.patch_size, config.patch_size)
									)

									UpperCamelCase__         = image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
									UpperCamelCase__         = image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

									for model_class in self.all_model_classes:
															UpperCamelCase__         = True
															self.check_hidden_states_output(UpperCamelCase_ ,      UpperCamelCase_ ,      UpperCamelCase_ ,      (padded_height, padded_width)			)

															# check that output_hidden_states also work using config
															del inputs_dict["output_hidden_states"]
															UpperCamelCase__         = True
															self.check_hidden_states_output(UpperCamelCase_ ,      UpperCamelCase_ ,      UpperCamelCase_ ,      (padded_height, padded_width)			)






			@unittest.skip(reason="""MaskFormerSwin doesn't have pretrained checkpoints"""			)
			def 				A      (   self							:						Dict			)							->    int:

									'''simple docstring'''







									pass






			@unittest.skip(reason="""This will be fixed once MaskFormerSwin is replaced by native Swin"""			)
			def 				A      (   self							:						str			)							->    List[str]:

									'''simple docstring'''







									pass






			@unittest.skip(reason="""This will be fixed once MaskFormerSwin is replaced by native Swin"""			)
			def 				A      (   self							:						str			)							->    Union[str, Any]:

									'''simple docstring'''







									pass







			def 				A      (   self							:						List[Any]			)							->    Union[str, Any]:

									'''simple docstring'''







									UpperCamelCase__    ,   UpperCamelCase__         = self.model_tester.prepare_config_and_inputs_for_common()

									def set_nan_tensor_to_zero(lowercase							:						Optional[int]			):
															UpperCamelCase__         = 0
															return t

									def check_equivalence(lowercase							:						List[Any] ,      lowercase							:						List[Any] ,      lowercase							:						Tuple ,      lowercase							:						Any={}			):
															with torch.no_grad():
																					UpperCamelCase__         = model(**UpperCamelCase_ ,      return_dict=UpperCamelCase_ ,      **UpperCamelCase_			)
																					UpperCamelCase__         = model(**UpperCamelCase_ ,      return_dict=UpperCamelCase_ ,      **UpperCamelCase_			).to_tuple()

																					def recursive_check(lowercase							:						str ,      lowercase							:						List[str]			):
																											if isinstance(UpperCamelCase_ ,      (List, Tuple)			):
																																	for tuple_iterable_value, dict_iterable_value in zip(UpperCamelCase_ ,      UpperCamelCase_			):
																																							recursive_check(UpperCamelCase_ ,      UpperCamelCase_			)
																											elif isinstance(UpperCamelCase_ ,      UpperCamelCase_			):
																																	for tuple_iterable_value, dict_iterable_value in zip(
																																	    tuple_object.values() ,      dict_object.values()			):
																																							recursive_check(UpperCamelCase_ ,      UpperCamelCase_			)
																											elif tuple_object is None:
																																	return
																											else:
																																	self.assertTrue(
																																	    torch.allclose(
																																	        set_nan_tensor_to_zero(UpperCamelCase_			) ,      set_nan_tensor_to_zero(UpperCamelCase_			) ,      atol=1e-5			) ,      msg=(
																																	        """Tuple and dict output are not equal. Difference:"""
																																	        f" {torch.max(torch.abs(tuple_object - dict_object			)			)}. Tuple has `nan`:"
																																	        f" {torch.isnan(UpperCamelCase_			).any()} and `inf`: {torch.isinf(UpperCamelCase_			)}. Dict has"
																																	        f" `nan`: {torch.isnan(UpperCamelCase_			).any()} and `inf`: {torch.isinf(UpperCamelCase_			)}."
																																	    ) ,      )

																					recursive_check(UpperCamelCase_ ,      UpperCamelCase_			)

									for model_class in self.all_model_classes:
															UpperCamelCase__         = model_class(UpperCamelCase_			)
															model.to(UpperCamelCase_			)
															model.eval()

															UpperCamelCase__         = self._prepare_for_class(UpperCamelCase_ ,      UpperCamelCase_			)
															UpperCamelCase__         = self._prepare_for_class(UpperCamelCase_ ,      UpperCamelCase_			)
															check_equivalence(UpperCamelCase_ ,      UpperCamelCase_ ,      UpperCamelCase_			)

															UpperCamelCase__         = self._prepare_for_class(UpperCamelCase_ ,      UpperCamelCase_ ,      return_labels=UpperCamelCase_			)
															UpperCamelCase__         = self._prepare_for_class(UpperCamelCase_ ,      UpperCamelCase_ ,      return_labels=UpperCamelCase_			)
															check_equivalence(UpperCamelCase_ ,      UpperCamelCase_ ,      UpperCamelCase_			)

															UpperCamelCase__         = self._prepare_for_class(UpperCamelCase_ ,      UpperCamelCase_			)
															UpperCamelCase__         = self._prepare_for_class(UpperCamelCase_ ,      UpperCamelCase_			)
															check_equivalence(UpperCamelCase_ ,      UpperCamelCase_ ,      UpperCamelCase_ ,      {"""output_hidden_states""": True}			)

															UpperCamelCase__         = self._prepare_for_class(UpperCamelCase_ ,      UpperCamelCase_ ,      return_labels=UpperCamelCase_			)
															UpperCamelCase__         = self._prepare_for_class(UpperCamelCase_ ,      UpperCamelCase_ ,      return_labels=UpperCamelCase_			)
															check_equivalence(UpperCamelCase_ ,      UpperCamelCase_ ,      UpperCamelCase_ ,      {"""output_hidden_states""": True}			)
@require_torch
class    _SCREAMING_SNAKE_CASE							(		unittest.TestCase       ,__lowerCamelCase	):


			'''simple docstring'''





			__a							:							Dict					     =					(MaskFormerSwinBackbone,) if is_torch_available() else ()
			__a							:							Union[str, Any]					     =					MaskFormerSwinConfig






			def 				A      (   self							:						Optional[Any]			)							->    List[str]:

									'''simple docstring'''







									UpperCamelCase__         = MaskFormerSwinModelTester(self			)







			def 				A      (   self							:						Any			)							->    Optional[int]:

									'''simple docstring'''







									UpperCamelCase__    ,   UpperCamelCase__         = self.model_tester.prepare_config_and_inputs_for_common()
									UpperCamelCase__         = inputs_dict["""pixel_values"""].shape[0]

									for backbone_class in self.all_model_classes:
															UpperCamelCase__         = backbone_class(UpperCamelCase_			)
															backbone.to(UpperCamelCase_			)
															backbone.eval()

															UpperCamelCase__         = backbone(**UpperCamelCase_			)

															# Test default outputs and verify feature maps
															self.assertIsInstance(outputs.feature_maps ,      UpperCamelCase_			)
															self.assertTrue(len(outputs.feature_maps			) == len(backbone.channels			)			)
															for feature_map, n_channels in zip(outputs.feature_maps ,      backbone.channels			):
																					self.assertTrue(feature_map.shape[:2] ,      (batch_size, n_channels)			)
															self.assertIsNone(outputs.hidden_states			)
															self.assertIsNone(outputs.attentions			)

															# Test output_hidden_states=True
															UpperCamelCase__         = backbone(**UpperCamelCase_ ,      output_hidden_states=UpperCamelCase_			)
															self.assertIsNotNone(outputs.hidden_states			)
															self.assertTrue(len(outputs.hidden_states			) ,      len(backbone.stage_names			)			)
															# We skip the stem layer
															for hidden_states, n_channels in zip(outputs.hidden_states[1:] ,      backbone.channels			):
																					for hidden_state in hidden_states:
																											# Hidden states are in the format (batch_size, (height * width), n_channels)
																											UpperCamelCase__    ,   UpperCamelCase__    ,   UpperCamelCase__         = hidden_state.shape
																											self.assertTrue((h_batch_size, h_n_channels) ,      (batch_size, n_channels)			)

            # Test output_attentions=True
															if self.has_attentions:
																					UpperCamelCase__         = backbone(**UpperCamelCase_ ,      output_attentions=UpperCamelCase_			)
																					self.assertIsNotNone(outputs.attentions			)








'''simple docstring'''


from __future__ import annotations

from typing import Any
class    _SCREAMING_SNAKE_CASE							:


			'''simple docstring'''





			def __init__(   self							:						Union[str, Any] ,      lowercase							:						int			)							->    None:

									'''simple docstring'''







									UpperCamelCase__         = num_of_nodes
									UpperCamelCase__         = []
									UpperCamelCase__         = {}






			def 				A      (   self							:						Optional[Any] ,      lowercase							:						int ,      lowercase							:						int ,      lowercase							:						int			)							->    None:

									'''simple docstring'''







									self.m_edges.append([u_node, v_node, weight]			)






			def 				A      (   self							:						str ,      lowercase							:						int			)							->    int:

									'''simple docstring'''







									if self.m_component[u_node] == u_node:
															return u_node
									return self.find_component(self.m_component[u_node]			)






			def 				A      (   self							:						Union[str, Any] ,      lowercase							:						int			)							->    None:

									'''simple docstring'''







									if self.m_component[u_node] != u_node:
															for k in self.m_component:
																					UpperCamelCase__         = self.find_component(lowercase			)






			def 				A      (   self							:						Tuple ,      lowercase							:						list[int] ,      lowercase							:						int ,      lowercase							:						int			)							->    None:

									'''simple docstring'''







									if component_size[u_node] <= component_size[v_node]:
															UpperCamelCase__         = v_node
															component_size[v_node] += component_size[u_node]
															self.set_component(lowercase			)

									elif component_size[u_node] >= component_size[v_node]:
															UpperCamelCase__         = self.find_component(lowercase			)
															component_size[u_node] += component_size[v_node]
															self.set_component(lowercase			)







			def 				A      (   self							:						int			)							->    None:

									'''simple docstring'''







									UpperCamelCase__         = []
									UpperCamelCase__         = 0

									UpperCamelCase__         = [-1] * self.m_num_of_nodes

									# A list of components (initialized to all of the nodes)
									for node in range(self.m_num_of_nodes			):
															self.m_component.update({node: node}			)
															component_size.append(1			)

									UpperCamelCase__         = self.m_num_of_nodes

									while num_of_components > 1:
															for edge in self.m_edges:
																					UpperCamelCase__    ,   UpperCamelCase__    ,   UpperCamelCase__         = edge

																					UpperCamelCase__         = self.m_component[u]
																					UpperCamelCase__         = self.m_component[v]

																					if u_component != v_component:

																											for component in (u_component, v_component):
																																	if (
																																	    minimum_weight_edge[component] == -1
																																	    or minimum_weight_edge[component][2] > w
																																	):
																																							UpperCamelCase__         = [u, v, w]

															for edge in minimum_weight_edge:
																					if isinstance(lowercase ,      lowercase			):
																											UpperCamelCase__    ,   UpperCamelCase__    ,   UpperCamelCase__         = edge

																											UpperCamelCase__         = self.m_component[u]
																											UpperCamelCase__         = self.m_component[v]

																											if u_component != v_component:
																																	mst_weight += w
																																	self.union(lowercase ,      lowercase ,      lowercase			)
																																	print(f"Added edge [{u} - {v}]\nAdded weight: {w}\n"			)
																																	num_of_components -= 1

															UpperCamelCase__         = [-1] * self.m_num_of_nodes
									print(f"The total weight of the minimal spanning tree is: {mst_weight}"			)







def 	__magic_name__( ):
						'''simple docstring'''







if __name__ == "__main__":
					import doctest

					doctest.testmod()
