
from collections.abc import Callable






class        SCREAMING_SNAKE_CASE__    :

							"""simple docstring"""






							def __init__(  self     ,	SCREAMING_SNAKE_CASE_ = None			)->   None:





													'''simple docstring'''






													__UpperCamelCase       =			[]
													# Stores indexes of each item for supporting updates and deletion.
													__UpperCamelCase       =			{}
													# Stores current size of heap.
													__UpperCamelCase       =			0
													# Stores function used to evaluate the score of an item on which basis ordering
													# will be done.
													__UpperCamelCase       =			key or (lambda SCREAMING_SNAKE_CASE_			: x)



							def     A__		(  self     ,	SCREAMING_SNAKE_CASE_			)->   int | None:





													'''simple docstring'''






													return int((i - 1) / 2			) if i > 0 else None



							def     A__		(  self     ,	SCREAMING_SNAKE_CASE_			)->   int | None:





													'''simple docstring'''






													__UpperCamelCase       =			int(2 * i + 1			)
													return left if 0 < left < self.size else None



							def     A__		(  self     ,	SCREAMING_SNAKE_CASE_			)->   int | None:





													'''simple docstring'''






													__UpperCamelCase       =			int(2 * i + 2			)
													return right if 0 < right < self.size else None



							def     A__		(  self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_			)->   None:





													'''simple docstring'''






													__UpperCamelCase  ,							__UpperCamelCase       =			(
													    self.pos_map[self.arr[j][0]],
													    self.pos_map[self.arr[i][0]],
													)
													# Then swap the items in the list.
													__UpperCamelCase  ,							__UpperCamelCase       =			self.arr[j], self.arr[i]



							def     A__		(  self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_			)->   bool:





													'''simple docstring'''






													return self.arr[i][1] < self.arr[j][1]



							def     A__		(  self     ,	SCREAMING_SNAKE_CASE_			)->   int:





													'''simple docstring'''






													__UpperCamelCase       =			self._left(lowerCAmelCase_			)
													__UpperCamelCase       =			self._right(lowerCAmelCase_			)
													__UpperCamelCase       =			i

													if left is not None and not self._cmp(lowerCAmelCase_     ,	lowerCAmelCase_			):
																			__UpperCamelCase       =			left
													if right is not None and not self._cmp(lowerCAmelCase_     ,	lowerCAmelCase_			):
																			__UpperCamelCase       =			right

													return valid_parent



							def     A__		(  self     ,	SCREAMING_SNAKE_CASE_			)->   None:





													'''simple docstring'''






													__UpperCamelCase       =			self._parent(lowerCAmelCase_			)
													while parent is not None and not self._cmp(lowerCAmelCase_     ,	lowerCAmelCase_			):
																			self._swap(lowerCAmelCase_     ,	lowerCAmelCase_			)
																			__UpperCamelCase  ,							__UpperCamelCase       =			parent, self._parent(lowerCAmelCase_			)



							def     A__		(  self     ,	SCREAMING_SNAKE_CASE_			)->   None:





													'''simple docstring'''






													__UpperCamelCase       =			self._get_valid_parent(lowerCAmelCase_			)
													while valid_parent != index:
																			self._swap(lowerCAmelCase_     ,	lowerCAmelCase_			)
																			__UpperCamelCase  ,							__UpperCamelCase       =			valid_parent, self._get_valid_parent(lowerCAmelCase_			)



							def     A__		(  self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_			)->   None:





													'''simple docstring'''






													if item not in self.pos_map:
																			return
													__UpperCamelCase       =			self.pos_map[item]
													__UpperCamelCase       =			[item, self.key(lowerCAmelCase_			)]
													# Make sure heap is right in both up and down direction.
													# Ideally only one of them will make any change.
													self._heapify_up(lowerCAmelCase_			)
													self._heapify_down(lowerCAmelCase_			)



							def     A__		(  self     ,	SCREAMING_SNAKE_CASE_			)->   None:





													'''simple docstring'''






													if item not in self.pos_map:
																			return
													__UpperCamelCase       =			self.pos_map[item]
													del self.pos_map[item]
													__UpperCamelCase       =			self.arr[self.size - 1]
													__UpperCamelCase       =			index
													self.size -= 1
													# Make sure heap is right in both up and down direction. Ideally only one
													# of them will make any change- so no performance loss in calling both.
													if self.size > index:
																			self._heapify_up(lowerCAmelCase_			)
																			self._heapify_down(lowerCAmelCase_			)



							def     A__		(  self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_			)->   None:





													'''simple docstring'''






													__UpperCamelCase       =			len(self.arr			)
													if arr_len == self.size:
																			self.arr.append([item, self.key(lowerCAmelCase_			)]			)
													else:
																			__UpperCamelCase       =			[item, self.key(lowerCAmelCase_			)]
													__UpperCamelCase       =			self.size
													self.size += 1
													self._heapify_up(self.size - 1			)



							def     A__		(  self			)->   tuple | None:





													'''simple docstring'''






													return self.arr[0] if self.size else None



							def     A__		(  self			)->   tuple | None:





													'''simple docstring'''






													__UpperCamelCase       =			self.get_top()
													if top_item_tuple:
																			self.delete_item(top_item_tuple[0]			)
													return top_item_tuple





def 	A_ (							)      ->    Optional[int]:



						'''simple docstring'''










if __name__ == "__main__":
			import doctest

			doctest.testmod()






# coding=utf-8
# Copyright 2023 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 platform
import sys


lowercase__							:							List[str]									=			"3"

print("Python version:", sys.version)

print("OS platform:", platform.platform())
print("OS architecture:", platform.machine())

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())
except ImportError:
				print("Torch version:", None)

try:
				import transformers

				print("transformers version:", transformers.__version__)
except ImportError:
				print("transformers version:", None)




