
'''simple docstring'''


from collections.abc import Callable

class 	__lowercase				:

			def __init__(self			,   A = None      ):
								# Stores actual heap items.
								lowerCamelCase_					:      list     =		[]
								# Stores indexes of each item for supporting updates and deletion.
								lowerCamelCase_					:      dict     =		{}
								# Stores current size of heap.
								lowerCamelCase_					:      List[Any]     =		0
								# Stores function used to evaluate the score of an item on which basis ordering
								# will be done.
								lowerCamelCase_					:      int     =		key or (lambda A      : x)

			def        UpperCAmelCase__ (self			,   A      ):
								return int((i - 1) / 2      ) if i > 0 else None

			def        UpperCAmelCase__ (self			,   A      ):
								lowerCamelCase_					:      List[str]     =		int(2 * i + 1      )
								return left if 0 < left < self.size else None

			def        UpperCAmelCase__ (self			,   A      ):
								lowerCamelCase_					:      Optional[Any]     =		int(2 * i + 2      )
								return right if 0 < right < self.size else None

			def        UpperCAmelCase__ (self			,   A			,   A      ):
								lowerCamelCase_,      lowerCamelCase_					:      Any     =		(
								    self.pos_map[self.arr[j][0]],
								    self.pos_map[self.arr[i][0]],
								)
								# Then swap the items in the list.
								lowerCamelCase_,      lowerCamelCase_					:      int     =		self.arr[j], self.arr[i]

			def        UpperCAmelCase__ (self			,   A			,   A      ):
								return self.arr[i][1] < self.arr[j][1]

			def        UpperCAmelCase__ (self			,   A      ):
								lowerCamelCase_					:      Tuple     =		self._left(A      )
								lowerCamelCase_					:      List[str]     =		self._right(A      )
								lowerCamelCase_					:      int     =		i

								if left is not None and not self._cmp(A			,   A      ):
													lowerCamelCase_					:      int     =		left
								if right is not None and not self._cmp(A			,   A      ):
													lowerCamelCase_					:      List[Any]     =		right

								return valid_parent

			def        UpperCAmelCase__ (self			,   A      ):
								lowerCamelCase_					:      List[str]     =		self._parent(A      )
								while parent is not None and not self._cmp(A			,   A      ):
													self._swap(A			,   A      )
													lowerCamelCase_,      lowerCamelCase_					:      Optional[Any]     =		parent, self._parent(A      )

			def        UpperCAmelCase__ (self			,   A      ):
								lowerCamelCase_					:      List[Any]     =		self._get_valid_parent(A      )
								while valid_parent != index:
													self._swap(A			,   A      )
													lowerCamelCase_,      lowerCamelCase_					:      List[Any]     =		valid_parent, self._get_valid_parent(A      )

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

			def        UpperCAmelCase__ (self			,   A      ):
								if item not in self.pos_map:
													return
								lowerCamelCase_					:      List[Any]     =		self.pos_map[item]
								del self.pos_map[item]
								lowerCamelCase_					:      str     =		self.arr[self.size - 1]
								lowerCamelCase_					:      List[str]     =		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(A      )
													self._heapify_down(A      )

			def        UpperCAmelCase__ (self			,   A			,   A      ):
								lowerCamelCase_					:      Optional[Any]     =		len(self.arr      )
								if arr_len == self.size:
													self.arr.append([item, self.key(A      )]      )
								else:
													lowerCamelCase_					:      Any     =		[item, self.key(A      )]
								lowerCamelCase_					:      Optional[int]     =		self.size
								self.size += 1
								self._heapify_up(self.size - 1      )

			def        UpperCAmelCase__ (self      ):
								return self.arr[0] if self.size else None






			def        UpperCAmelCase__ (self      ):
								lowerCamelCase_					:      Union[str, Any]     =		self.get_top()
								if top_item_tuple:
													self.delete_item(top_item_tuple[0]      )
								return top_item_tuple




def lowercase_	(   )     ->							None:
					'''simple docstring'''



if __name__ == "__main__":
					import doctest

					doctest.testmod()




'''simple docstring'''


from typing import TYPE_CHECKING

from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__lowercase							:   str					=     {
    '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''],
    '''feature_extraction_mctct''': ['''MCTCTFeatureExtractor'''],
    '''processing_mctct''': ['''MCTCTProcessor'''],
}


try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__lowercase							:   str					=     [
					    '''MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''MCTCTForCTC''',
					    '''MCTCTModel''',
					    '''MCTCTPreTrainedModel''',
					]


if TYPE_CHECKING:
					from .configuration_mctct import MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP, MCTCTConfig
					from .feature_extraction_mctct import MCTCTFeatureExtractor
					from .processing_mctct import MCTCTProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_mctct import MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST, MCTCTForCTC, MCTCTModel, MCTCTPreTrainedModel

else:
					import sys

					__lowercase							:   Union[str, Any]					=     _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)


