
class 	A_       :




	'''simple docstring'''


	def __init__(	self	):
		lowercase					  =   {}
		# indexmap keys are an index and it's values are the number at that index
		lowercase					  =   {}





	def      SCREAMING_SNAKE_CASE__						(	self		,   snake_case		,   snake_case	):







		if isinstance(__UpperCamelCase		,   (range, str)	):
			lowercase					  =   list(__UpperCamelCase	)
		elif not isinstance(__UpperCamelCase		,   __UpperCamelCase	):
			raise TypeError(
			    'binary_search_delete() only accepts either a list, range or str'	)

		lowercase					  =   0
		lowercase					  =   len(__UpperCamelCase	) - 1

		while low <= high:
			lowercase					  =   (low + high) // 2
			if array[mid] == item:
				array.pop(__UpperCamelCase	)
				return array
			elif array[mid] < item:
				lowercase					  =   mid + 1
			else:
				lowercase					  =   mid - 1
		raise ValueError(
		    'Either the item is not in the array or the array was unsorted'	)





	def      SCREAMING_SNAKE_CASE__						(	self		,   snake_case		,   snake_case	):







		if isinstance(__UpperCamelCase		,   (range, str)	):
			lowercase					  =   list(__UpperCamelCase	)
		elif not isinstance(__UpperCamelCase		,   __UpperCamelCase	):
			raise TypeError(
			    'binary_search_insert() only accepts either a list, range or str'	)

		lowercase					  =   0
		lowercase					  =   len(__UpperCamelCase	) - 1

		while low <= high:
			lowercase					  =   (low + high) // 2
			if array[mid] == index:
				# If the item already exists in the array,
				# insert it after the existing item
				array.insert(mid + 1		,   __UpperCamelCase	)
				return array
			elif array[mid] < index:
				lowercase					  =   mid + 1
			else:
				lowercase					  =   mid - 1

        # If the item doesn't exist in the array, insert it at the appropriate position
		array.insert(__UpperCamelCase		,   __UpperCamelCase	)
		return array





	def      SCREAMING_SNAKE_CASE__						(	self		,   snake_case		,   snake_case	):







		if index in self.indexmap:
			lowercase					  =   self.indexmap[index]
			if len(self.numbermap[n]	) == 1:
				del self.numbermap[n]
			else:
				lowercase					  =   self.binary_search_delete(self.numbermap[n]		,   __UpperCamelCase	)

        # Set new index
		lowercase					  =   number

		# Number not seen before or empty so insert number value
		if number not in self.numbermap:
			lowercase					  =   [index]

		# Here we need to perform a binary search insertion in order to insert
		# The item in the correct place
		else:
			lowercase					  =   self.binary_search_insert(
			    self.numbermap[number]		,   __UpperCamelCase	)





	def      SCREAMING_SNAKE_CASE__						(	self		,   snake_case	):
		return self.numbermap.get(__UpperCamelCase		,   [-1]	)[0]


if __name__ == "__main__":
						import doctest

						doctest.testmod()



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCAmelCase     				=			{
    '''configuration_dpr''': ['''DPR_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DPRConfig'''],
    '''tokenization_dpr''': [
        '''DPRContextEncoderTokenizer''',
        '''DPRQuestionEncoderTokenizer''',
        '''DPRReaderOutput''',
        '''DPRReaderTokenizer''',
    ],
}


try:
	if not is_tokenizers_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	UpperCAmelCase     				=			[
	    '''DPRContextEncoderTokenizerFast''',
	    '''DPRQuestionEncoderTokenizerFast''',
	    '''DPRReaderTokenizerFast''',
	]

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	UpperCAmelCase     				=			[
	    '''DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST''',
	    '''DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST''',
	    '''DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST''',
	    '''DPRContextEncoder''',
	    '''DPRPretrainedContextEncoder''',
	    '''DPRPreTrainedModel''',
	    '''DPRPretrainedQuestionEncoder''',
	    '''DPRPretrainedReader''',
	    '''DPRQuestionEncoder''',
	    '''DPRReader''',
	]

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	UpperCAmelCase     				=			[
	    '''TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST''',
	    '''TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST''',
	    '''TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST''',
	    '''TFDPRContextEncoder''',
	    '''TFDPRPretrainedContextEncoder''',
	    '''TFDPRPretrainedQuestionEncoder''',
	    '''TFDPRPretrainedReader''',
	    '''TFDPRQuestionEncoder''',
	    '''TFDPRReader''',
	]


if TYPE_CHECKING:
	from .configuration_dpr import DPR_PRETRAINED_CONFIG_ARCHIVE_MAP, DPRConfig
	from .tokenization_dpr import (
	    DPRContextEncoderTokenizer,
	    DPRQuestionEncoderTokenizer,
	    DPRReaderOutput,
	    DPRReaderTokenizer,
	)

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_dpr_fast import (
		    DPRContextEncoderTokenizerFast,
		    DPRQuestionEncoderTokenizerFast,
		    DPRReaderTokenizerFast,
		)

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_dpr import (
		    DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    DPRContextEncoder,
		    DPRPretrainedContextEncoder,
		    DPRPreTrainedModel,
		    DPRPretrainedQuestionEncoder,
		    DPRPretrainedReader,
		    DPRQuestionEncoder,
		    DPRReader,
		)

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_dpr import (
		    TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFDPRContextEncoder,
		    TFDPRPretrainedContextEncoder,
		    TFDPRPretrainedQuestionEncoder,
		    TFDPRPretrainedReader,
		    TFDPRQuestionEncoder,
		    TFDPRReader,
		)

else:
	import sys

	UpperCAmelCase     				=			_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)

