



'''simple docstring'''





from __future__ import annotations

from sys import maxsize
from typing import Generic, TypeVar

_lowerCAmelCase      						=	TypeVar('''T''')
def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    return (position - 1) // 2
def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    return (2 * position) + 1
def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    return (2 * position) + 2






class        lowerCAmelCase_(				Generic[T]     ):
  '''simple docstring'''




  def __init__(    self      )    ->		None:
      lowerCAmelCase__ :  list[tuple[T, int]]							      =					[]
      lowerCAmelCase__ :  dict[T, int]							      =					{}
      lowerCAmelCase__ :  int							      =					0




  def __len__(    self      )    ->		int:
      return self.elements




  def __repr__(    self      )    ->		str:
      return str(self.heap      )




  def 							UpperCAmelCase_	(    self      )    ->		bool:
      # Check if the priority queue is empty
      return self.elements == 0




  def 							UpperCAmelCase_	(    self  ,__UpperCAmelCase  ,__UpperCAmelCase      )    ->		None:
      # Add an element with given priority to the queue
      self.heap.append((elem, weight)      )
      lowerCAmelCase__ :  str							      =					self.elements
      self.elements += 1
      self._bubble_up(__UpperCAmelCase      )




  def 							UpperCAmelCase_	(    self      )    ->		T:
      # Remove and return the element with lowest weight (highest priority)
      if self.elements > 1:
          self._swap_nodes(0  ,self.elements - 1      )
      lowerCAmelCase__      ,   lowerCAmelCase__ :  Optional[int]							      =					self.heap.pop()
      del self.position_map[elem]
      self.elements -= 1
      if self.elements > 0:
          lowerCAmelCase__      ,   lowerCAmelCase__ :  str							      =					self.heap[0]
          self._bubble_down(__UpperCAmelCase      )
      return elem




  def 							UpperCAmelCase_	(    self  ,__UpperCAmelCase  ,__UpperCAmelCase      )    ->		None:
      # Update the weight of the given key
      lowerCAmelCase__ :  int							      =					self.position_map[elem]
      lowerCAmelCase__ :  List[Any]							      =					(elem, weight)
      if position > 0:
          lowerCAmelCase__ :  Dict							      =					get_parent_position(__UpperCAmelCase      )
          lowerCAmelCase__      ,   lowerCAmelCase__ :  Optional[int]							      =					self.heap[parent_position]
          if parent_weight > weight:
              self._bubble_up(__UpperCAmelCase      )
          else:
              self._bubble_down(__UpperCAmelCase      )
      else:
          self._bubble_down(__UpperCAmelCase      )




  def 							UpperCAmelCase_	(    self  ,__UpperCAmelCase      )    ->		None:
      # Place a node at the proper position (upward movement) [to be used internally
      # only]
      lowerCAmelCase__ :  List[str]							      =					self.position_map[elem]
      if curr_pos == 0:
          return None
      lowerCAmelCase__ :  int							      =					get_parent_position(__UpperCAmelCase      )
      lowerCAmelCase__      ,   lowerCAmelCase__ :  Any							      =					self.heap[curr_pos]
      lowerCAmelCase__      ,   lowerCAmelCase__ :  List[str]							      =					self.heap[parent_position]
      if parent_weight > weight:
          self._swap_nodes(__UpperCAmelCase  ,__UpperCAmelCase      )
          return self._bubble_up(__UpperCAmelCase      )
      return None




  def 							UpperCAmelCase_	(    self  ,__UpperCAmelCase      )    ->		None:
      # Place a node at the proper position (downward movement) [to be used
      # internally only]
      lowerCAmelCase__ :  List[Any]							      =					self.position_map[elem]
      lowerCAmelCase__      ,   lowerCAmelCase__ :  Dict							      =					self.heap[curr_pos]
      lowerCAmelCase__ :  str							      =					get_child_left_position(__UpperCAmelCase      )
      lowerCAmelCase__ :  Union[str, Any]							      =					get_child_right_position(__UpperCAmelCase      )
      if child_left_position < self.elements and child_right_position < self.elements:
          lowerCAmelCase__      ,   lowerCAmelCase__ :  Dict							      =					self.heap[child_left_position]
          lowerCAmelCase__      ,   lowerCAmelCase__ :  Any							      =					self.heap[child_right_position]
          if child_right_weight < child_left_weight and child_right_weight < weight:
              self._swap_nodes(__UpperCAmelCase  ,__UpperCAmelCase      )
              return self._bubble_down(__UpperCAmelCase      )
      if child_left_position < self.elements:
          lowerCAmelCase__      ,   lowerCAmelCase__ :  List[str]							      =					self.heap[child_left_position]
          if child_left_weight < weight:
              self._swap_nodes(__UpperCAmelCase  ,__UpperCAmelCase      )
              return self._bubble_down(__UpperCAmelCase      )
      else:
          return None
      if child_right_position < self.elements:
          lowerCAmelCase__      ,   lowerCAmelCase__ :  Any							      =					self.heap[child_right_position]
          if child_right_weight < weight:
              self._swap_nodes(__UpperCAmelCase  ,__UpperCAmelCase      )
              return self._bubble_down(__UpperCAmelCase      )
      return None






  def 							UpperCAmelCase_	(    self  ,__UpperCAmelCase  ,__UpperCAmelCase      )    ->		None:
      # Swap the nodes at the given positions
      lowerCAmelCase__ :  str							      =					self.heap[nodea_pos][0]
      lowerCAmelCase__ :  Dict							      =					self.heap[nodea_pos][0]
      lowerCAmelCase__      ,   lowerCAmelCase__ :  Tuple							      =					(
          self.heap[nodea_pos],
          self.heap[nodea_pos],
      )
      lowerCAmelCase__ :  int							      =					nodea_pos
      lowerCAmelCase__ :  int							      =					nodea_pos







class        lowerCAmelCase_(				Generic[T]     ):
  '''simple docstring'''




  def __init__(    self      )    ->		None:
      lowerCAmelCase__ :  dict[T, dict[T, int]]							      =					{}
      lowerCAmelCase__ :  int							      =					0




  def __repr__(    self      )    ->		str:
      return str(self.connections      )




  def __len__(    self      )    ->		int:
      return self.nodes




  def 							UpperCAmelCase_	(    self  ,__UpperCAmelCase      )    ->		None:
      # Add a node in the graph if it is not in the graph
      if node not in self.connections:
          lowerCAmelCase__ :  Optional[int]							      =					{}
          self.nodes += 1






  def 							UpperCAmelCase_	(    self  ,__UpperCAmelCase  ,__UpperCAmelCase  ,__UpperCAmelCase      )    ->		None:
      # Add an edge between 2 nodes in the graph
      self.add_node(__UpperCAmelCase      )
      self.add_node(__UpperCAmelCase      )
      lowerCAmelCase__ :  Any							      =					weight
      lowerCAmelCase__ :  Tuple							      =					weight







def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase							,    ):



    """simple docstring"""





    lowerCAmelCase__ :  dict[T, int]							      =					{node: maxsize for node in graph.connections}
    lowerCAmelCase__ :  dict[T, T | None]							      =					{node: None for node in graph.connections}

    lowerCAmelCase__ :  MinPriorityQueue[T]							      =					MinPriorityQueue()
    for node, weight in dist.items():
        priority_queue.push(UpperCamelCase							,    UpperCamelCase			)

    if priority_queue.is_empty():
        return dist, parent

    # initialization
    lowerCAmelCase__ :  List[Any]							      =					priority_queue.extract_min()
    lowerCAmelCase__ :  str							      =					0
    for neighbour in graph.connections[node]:
        if dist[neighbour] > dist[node] + graph.connections[node][neighbour]:
            lowerCAmelCase__ :  Any							      =					dist[node] + graph.connections[node][neighbour]
            priority_queue.update_key(UpperCamelCase							,    dist[neighbour]			)
            lowerCAmelCase__ :  List[str]							      =					node

    # running prim's algorithm
    while not priority_queue.is_empty():
        lowerCAmelCase__ :  Any							      =					priority_queue.extract_min()
        for neighbour in graph.connections[node]:
            if dist[neighbour] > dist[node] + graph.connections[node][neighbour]:
                lowerCAmelCase__ :  Optional[int]							      =					dist[node] + graph.connections[node][neighbour]
                priority_queue.update_key(UpperCamelCase							,    dist[neighbour]			)
                lowerCAmelCase__ :  Optional[int]							      =					node
    return dist, parent







'''simple docstring'''





# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team.
#
# 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.

# this script dumps information about the environment

import os
import sys

import transformers


_lowerCAmelCase      						=	'''3'''

print('''Python version:''', sys.version)
print('''transformers version:''', transformers.__version__)

try:
 import torch

 print('''Torch version:''', torch.__version__)
 print('''Cuda available:''', torch.cuda.is_available())
 print('''Cuda version:''', torch.version.cuda)
 print('''CuDNN version:''', torch.backends.cudnn.version())
 print('''Number of GPUs available:''', torch.cuda.device_count())
 print('''NCCL version:''', torch.cuda.nccl.version())
except ImportError:
 print('''Torch version:''', None)

try:
 import deepspeed

 print('''DeepSpeed version:''', deepspeed.__version__)
except ImportError:
 print('''DeepSpeed version:''', None)

try:
 import tensorflow as tf

 print('''TensorFlow version:''', tf.__version__)
 print('''TF GPUs available:''', bool(tf.config.list_physical_devices('''GPU''')))
 print('''Number of TF GPUs available:''', len(tf.config.list_physical_devices('''GPU''')))
except ImportError:
 print('''TensorFlow version:''', None)


