


# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import os
import platform

import numpy as np
import psutil
import torch

from accelerate import __version__ as version
from accelerate.commands.config import default_config_file, load_config_from_file

from ..utils import is_npu_available, is_xpu_available

def       lowercase_		(		_A			:    Union[str, Any]=None						):

      """simple docstring"""




      if subparsers is not None:
            lowerCamelCase__		:				Any    =  subparsers.add_parser("env"						)
      else:
            lowerCamelCase__		:				Optional[Any]    =  argparse.ArgumentParser("Accelerate env command"						)

      parser.add_argument(
          "--config_file"    ,					default=__SCREAMING_SNAKE_CASE    ,					help="The config file to use for the default values in the launching script."						)

      if subparsers is not None:
            parser.set_defaults(func=__SCREAMING_SNAKE_CASE						)
      return parser

def       lowercase_		(		_A			:    List[str]						):

      """simple docstring"""




      lowerCamelCase__		:				Any    =  torch.__version__
      lowerCamelCase__		:				Union[str, Any]    =  torch.cuda.is_available()
      lowerCamelCase__		:				Union[str, Any]    =  is_xpu_available()
      lowerCamelCase__		:				List[Any]    =  is_npu_available()

      lowerCamelCase__		:				List[Any]    =  "Not found"
      # Get the default from the config file.
      if args.config_file is not None or os.path.isfile(__SCREAMING_SNAKE_CASE						):
            lowerCamelCase__		:				int    =  load_config_from_file(args.config_file						).to_dict()

      lowerCamelCase__		:				Optional[int]    =  {
          "`Accelerate` version": version,
          "Platform": platform.platform(),
          "Python version": platform.python_version(),
          "Numpy version": np.__version__,
          "PyTorch version (GPU?)": F"{pt_version} ({pt_cuda_available})",
          "PyTorch XPU available": str(__SCREAMING_SNAKE_CASE						),
          "PyTorch NPU available": str(__SCREAMING_SNAKE_CASE						),
          "System RAM": F"{psutil.virtual_memory().total / 1024 ** 3:.2f} GB",
      }
      if pt_cuda_available:
            lowerCamelCase__		:				Dict    =  torch.cuda.get_device_name()

      print("\nCopy-and-paste the text below in your GitHub issue\n"						)
      print("\n".join([F"- {prop}: {val}" for prop, val in info.items()]						)						)

      print("- `Accelerate` default config:" if args.config_file is None else "- `Accelerate` config passed:"						)
      lowerCamelCase__		:				List[Any]    =  (
          "\n".join([F"\t- {prop}: {val}" for prop, val in accelerate_config.items()]						)
          if isinstance(__SCREAMING_SNAKE_CASE    ,					__SCREAMING_SNAKE_CASE						)
          else F"\t{accelerate_config}"
      )
      print(__SCREAMING_SNAKE_CASE						)

      lowerCamelCase__		:				str    =  accelerate_config

      return info

def       lowercase_		(		):

      """simple docstring"""




      lowerCamelCase__		:				str    =  env_command_parser()
      lowerCamelCase__		:				Optional[Any]    =  parser.parse_args()
      env_command(__SCREAMING_SNAKE_CASE						)
      return 0


if __name__ == "__main__":
    raise SystemExit(main())




import sys
from collections import defaultdict







class        A_   :




	'''simple docstring'''


	def __init__(       self       ):
		lowercase       =    []





	def 	SCREAMING_SNAKE_CASE__						(       self		,    snake_case       ):
		return self.node_position[vertex]





	def 	SCREAMING_SNAKE_CASE__						(       self		,    snake_case		,    snake_case       ):
		lowercase       =    pos





	def 	SCREAMING_SNAKE_CASE__						(       self		,    snake_case		,    snake_case		,    snake_case		,    snake_case       ):
		if start > size // 2 - 1:
			return
		else:
			if 2 * start + 2 >= size:
				lowercase       =    2 * start + 1
			else:
				if heap[2 * start + 1] < heap[2 * start + 2]:
					lowercase       =    2 * start + 1
				else:
					lowercase       =    2 * start + 2
			if heap[smallest_child] < heap[start]:
				lowercase  ,					lowercase       =    heap[smallest_child], positions[smallest_child]
				lowercase  ,					lowercase       =    (
				    heap[start],
				    positions[start],
				)
				lowercase  ,					lowercase       =    temp, tempa

				lowercase       =    self.get_position(positions[smallest_child]       )
				self.set_position(
				    positions[smallest_child]		,    self.get_position(positions[start]       )       )
				self.set_position(positions[start]		,    snake_case       )

				self.top_to_bottom(snake_case		,    snake_case		,    snake_case		,    snake_case       )





	def 	SCREAMING_SNAKE_CASE__						(       self		,    snake_case		,    snake_case		,    snake_case		,    snake_case       ):
		lowercase       =    position[index]

		while index != 0:
			lowercase       =    int((index - 2) / 2       ) if index % 2 == 0 else int((index - 1) / 2       )

			if val < heap[parent]:
				lowercase       =    heap[parent]
				lowercase       =    position[parent]
				self.set_position(position[parent]		,    snake_case       )
			else:
				lowercase       =    val
				lowercase       =    temp
				self.set_position(snake_case		,    snake_case       )
				break
			lowercase       =    parent
		else:
			lowercase       =    val
			lowercase       =    temp
			self.set_position(snake_case		,    0       )





	def 	SCREAMING_SNAKE_CASE__						(       self		,    snake_case		,    snake_case       ):
		lowercase       =    len(snake_case       ) // 2 - 1
		for i in range(snake_case		,    -1		,    -1       ):
			self.top_to_bottom(snake_case		,    snake_case		,    len(snake_case       )		,    snake_case       )





	def 	SCREAMING_SNAKE_CASE__						(       self		,    snake_case		,    snake_case       ):
		lowercase       =    positions[0]
		lowercase       =    sys.maxsize
		self.top_to_bottom(snake_case		,    0		,    len(snake_case       )		,    snake_case       )
		return temp






def 							UpperCAmelCase_		(							__SCREAMING_SNAKE_CASE							):
	lowercase       =    Heap()

	lowercase       =    [0] * len(__SCREAMING_SNAKE_CASE							)
	lowercase       =    [-1] * len(__SCREAMING_SNAKE_CASE							)  # Neighboring Tree Vertex of selected vertex
	# Minimum Distance of explored vertex with neighboring vertex of partial tree
	# formed in graph
	lowercase       =    []  # Heap of Distance of vertices from their neighboring vertex
	lowercase       =    []

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

	lowercase       =    []
	lowercase       =    1
	lowercase       =    sys.maxsize
	for neighbor, distance in adjacency_list[0]:
		lowercase       =    0
		lowercase       =    distance
	heap.heapify(__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE							)

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


if __name__ == "__main__":  # pragma: no cover
	# < --------- Prims Algorithm --------- >
	UpperCAmelCase	      = int(input('''Enter number of edges: ''').strip())
	UpperCAmelCase	      = defaultdict(list)
	for _ in range(edges_number):
		UpperCAmelCase	      = [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))

