





import sys
from collections import defaultdict



class 					A__   :





      def __init__( self   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[Any]       	=   []





      def        __UpperCamelCase( self       ,							A_   ):
       '''simple docstring'''




       return self.node_position[vertex]





      def        __UpperCamelCase( self       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[Any]       	=   pos





      def        __UpperCamelCase( self       ,							A_       ,							A_       ,							A_       ,							A_   ):
       '''simple docstring'''




       if start > size // 2 - 1:
        return
       else:
        if 2 * start + 2 >= size:
         UpperCamelCase	:					List[Any]       	=   2 * start + 1
        else:
         if heap[2 * start + 1] < heap[2 * start + 2]:
          UpperCamelCase	:					Any       	=   2 * start + 1
         else:
          UpperCamelCase	:					str       	=   2 * start + 2
        if heap[smallest_child] < heap[start]:
         UpperCamelCase	,    UpperCamelCase	:					str       	=   heap[smallest_child], positions[smallest_child]
         UpperCamelCase	,    UpperCamelCase	:					Union[str, Any]       	=   (
             heap[start],
             positions[start],
         )
         UpperCamelCase	,    UpperCamelCase	:					Optional[Any]       	=   temp, tempa

         UpperCamelCase	:					Any       	=   self.get_position(positions[smallest_child]   )
         self.set_position(
             positions[smallest_child]       ,							self.get_position(positions[start]   )   )
         self.set_position(positions[start]       ,							A_   )

         self.top_to_bottom(A_       ,							A_       ,							A_       ,							A_   )





      def        __UpperCamelCase( self       ,							A_       ,							A_       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Any       	=   position[index]

       while index != 0:
        UpperCamelCase	:					Optional[Any]       	=   int((index - 2) / 2   ) if index % 2 == 0 else int((index - 1) / 2   )

        if val < heap[parent]:
         UpperCamelCase	:					Dict       	=   heap[parent]
         UpperCamelCase	:					int       	=   position[parent]
         self.set_position(position[parent]       ,							A_   )
        else:
         UpperCamelCase	:					Optional[int]       	=   val
         UpperCamelCase	:					Tuple       	=   temp
         self.set_position(A_       ,							A_   )
         break
        UpperCamelCase	:					List[Any]       	=   parent
       else:
        UpperCamelCase	:					Dict       	=   val
        UpperCamelCase	:					Tuple       	=   temp
        self.set_position(A_       ,							0   )





      def        __UpperCamelCase( self       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Tuple       	=   len(A_   ) // 2 - 1
       for i in range(A_       ,							-1       ,							-1   ):
        self.top_to_bottom(A_       ,							A_       ,							len(A_   )       ,							A_   )





      def        __UpperCamelCase( self       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[Any]       	=   positions[0]
       UpperCamelCase	:					Any       	=   sys.maxsize
       self.top_to_bottom(A_       ,							0       ,							len(A_   )       ,							A_   )
       return temp



def 		A_				(     _lowerCAmelCase     )						-> Any:
 UpperCamelCase	:					List[Any]       	=   Heap()

 UpperCamelCase	:					Union[str, Any]       	=   [0] * len(_lowerCAmelCase     )
 UpperCamelCase	:					Union[str, Any]       	=   [-1] * len(_lowerCAmelCase     )  # Neighboring Tree Vertex of selected vertex
 # Minimum Distance of explored vertex with neighboring vertex of partial tree
 # formed in graph
 UpperCamelCase	:					Tuple       	=   []  # Heap of Distance of vertices from their neighboring vertex
 UpperCamelCase	:					Optional[Any]       	=   []

 for vertex in range(len(_lowerCAmelCase     )     ):
  distance_tv.append(sys.maxsize     )
  positions.append(_lowerCAmelCase     )
  heap.node_position.append(_lowerCAmelCase     )

 UpperCamelCase	:					int       	=   []
 UpperCamelCase	:					Any       	=   1
 UpperCamelCase	:					List[Any]       	=   sys.maxsize
 for neighbor, distance in adjacency_list[0]:
  UpperCamelCase	:					List[Any]       	=   0
  UpperCamelCase	:					int       	=   distance
 heap.heapify(_lowerCAmelCase							,   _lowerCAmelCase     )

 for _ in range(1							,   len(_lowerCAmelCase     )     ):
  UpperCamelCase	:					str       	=   heap.delete_minimum(_lowerCAmelCase							,   _lowerCAmelCase     )
  if visited[vertex] == 0:
   tree_edges.append((nbr_tv[vertex], vertex)     )
   UpperCamelCase	:					Tuple       	=   1
   for neighbor, distance in adjacency_list[vertex]:
    if (
        visited[neighbor] == 0
        and distance < distance_tv[heap.get_position(_lowerCAmelCase     )]
    ):
     UpperCamelCase	:					Any       	=   distance
     heap.bottom_to_top(
         _lowerCAmelCase							,   heap.get_position(_lowerCAmelCase     )							,   _lowerCAmelCase							,   _lowerCAmelCase     )
     UpperCamelCase	:					Union[str, Any]       	=   vertex
 return tree_edges


if __name__ == "__main__":  # pragma: no cover
    # < --------- Prims Algorithm --------- >
    __lowerCamelCase       :     Any   =     int(input("""Enter number of edges: """).strip())
    __lowerCamelCase       :     Optional[Any]   =     defaultdict(list)
    for _ in range(edges_number):
        __lowerCamelCase       :     Optional[int]   =     [int(x) for x in input().strip().split()]
        adjacency_list[edge[0]].append([edge[1], edge[2]])
        adjacency_list[edge[1]].append([edge[0], edge[2]])
    print(prisms_algorithm(adjacency_list))

'''simple docstring'''

import argparse

import torch
from torch import nn

from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration







def      UpperCamelCase_						(					snake_case_       :       Any      )					->     Optional[Any]:






 '''simple docstring'''

 __lowerCAmelCase											=						[
     """encoder.version""",
     """decoder.version""",
     """model.encoder.version""",
     """model.decoder.version""",
     """decoder.output_projection.weight""",
     """_float_tensor""",
     """encoder.embed_positions._float_tensor""",
     """decoder.embed_positions._float_tensor""",
 ]
 for k in ignore_keys:
  state_dict.pop(snake_case_						,		snake_case_      )







def      UpperCamelCase_						(					snake_case_       :       Optional[Any]      )					->     List[Any]:






 '''simple docstring'''

 __lowerCAmelCase							,       __lowerCAmelCase											=						emb.weight.shape
 __lowerCAmelCase											=						nn.Linear(snake_case_						,		snake_case_						,		bias=snake_case_      )
 __lowerCAmelCase											=						emb.weight.data
 return lin_layer







def      UpperCamelCase_						(					snake_case_       :       Any      )					->     Any:






 '''simple docstring'''

 __lowerCAmelCase											=						torch.load(snake_case_						,		map_location="""cpu"""      )
 __lowerCAmelCase											=						mam_aaa["""args"""] or mam_aaa["""cfg"""]["""model"""]
 __lowerCAmelCase											=						mam_aaa["""model"""]
 remove_ignore_keys_(snake_case_      )
 __lowerCAmelCase											=						state_dict["""encoder.embed_tokens.weight"""].shape[0]

 __lowerCAmelCase											=						MaMaaaConfig(
     vocab_size=snake_case_						,		max_position_embeddings=10_24						,		encoder_layers=args.encoder_layers						,		decoder_layers=args.decoder_layers						,		encoder_attention_heads=args.encoder_attention_heads						,		decoder_attention_heads=args.decoder_attention_heads						,		encoder_ffn_dim=args.encoder_ffn_embed_dim						,		decoder_ffn_dim=args.decoder_ffn_embed_dim						,		d_model=args.encoder_embed_dim						,		encoder_layerdrop=args.encoder_layerdrop						,		decoder_layerdrop=args.decoder_layerdrop						,		dropout=args.dropout						,		attention_dropout=args.attention_dropout						,		activation_dropout=args.activation_dropout						,		activation_function="""relu"""						,		)

 __lowerCAmelCase											=						state_dict["""decoder.embed_tokens.weight"""]
 __lowerCAmelCase											=						MaMaaaForConditionalGeneration(snake_case_      )
 model.model.load_state_dict(snake_case_						,		strict=snake_case_      )
 __lowerCAmelCase											=						make_linear_from_emb(model.model.shared      )

 return model


if __name__ == "__main__":
 _A			:      Union[str, Any]					      =				argparse.ArgumentParser()
 # Required parameters
 parser.add_argument('''fairseq_path''', type=str, help='''path to a model.pt on local filesystem.''')
 parser.add_argument('''pytorch_dump_folder_path''', default=None, type=str, help='''Path to the output PyTorch model.''')
 _A			:      str					      =				parser.parse_args()
 _A			:      Optional[int]					      =				convert_fairseq_mamaaa_checkpoint_from_disk(args.fairseq_pathß)
 model.save_pretrained(args.pytorch_dump_folder_path)






