



'''simple docstring'''



lowerCAmelCase	:		int				=   '''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'''



def   __lowerCAmelCase					(							lowerCamelCase   :						bytes					):






	'''simple docstring'''




	if not isinstance(lowerCamelCase				,		lowerCamelCase					):
		__lowerCAmelCase												=  f'''a bytes-like object is required, not \'{data.__class__.__name__}\''''
		raise TypeError(lowerCamelCase					)

	__lowerCAmelCase												=  "".join(bin(lowerCamelCase					)[2:].zfill(8					) for byte in data					)

	__lowerCAmelCase												=  len(lowerCamelCase					) % 6 != 0

	if padding_needed:
		# The padding that will be added later
		__lowerCAmelCase												=  B"=" * ((6 - len(lowerCamelCase					) % 6) // 2)

		# Append binary_stream with arbitrary binary digits (0's by default) to make its
		# length a multiple of 6.
		binary_stream += "0" * (6 - len(lowerCamelCase					) % 6)
	else:
		__lowerCAmelCase												=  B""

	# Encode every 6 binary digits to their corresponding Base64 character
	return (
	    "".join(
	        B64_CHARSET[int(binary_stream[index : index + 6]				,		2					)]
	        for index in range(0				,		len(lowerCamelCase					)				,		6					)					).encode()
	    + padding
	)



def   __lowerCAmelCase					(							lowerCamelCase   :						str					):






	'''simple docstring'''




	if not isinstance(lowerCamelCase				,		lowerCamelCase					) and not isinstance(lowerCamelCase				,		lowerCamelCase					):
		__lowerCAmelCase												=  (
		    "argument should be a bytes-like object or ASCII string, "
		    f'''not \'{encoded_data.__class__.__name__}\''''
		)
		raise TypeError(lowerCamelCase					)

	# In case encoded_data is a bytes-like object, make sure it contains only
	# ASCII characters so we convert it to a string object
	if isinstance(lowerCamelCase				,		lowerCamelCase					):
		try:
			__lowerCAmelCase												=  encoded_data.decode("utf-8"					)
		except UnicodeDecodeError:
			raise ValueError("base64 encoded data should only contain ASCII characters"					)

	__lowerCAmelCase												=  encoded_data.count("="					)

	# Check if the encoded string contains non base64 characters
	if padding:
		assert all(
		    char in B64_CHARSET for char in encoded_data[:-padding]					), "Invalid base64 character(s) found."
	else:
		assert all(
		    char in B64_CHARSET for char in encoded_data					), "Invalid base64 character(s) found."

	# Check the padding
	assert len(lowerCamelCase					) % 4 == 0 and padding < 3, "Incorrect padding"

	if padding:
		# Remove padding if there is one
		__lowerCAmelCase												=  encoded_data[:-padding]

		__lowerCAmelCase												=  "".join(
		    bin(B64_CHARSET.index(lowerCamelCase					)					)[2:].zfill(6					) for char in encoded_data					)[: -padding * 2]
	else:
		__lowerCAmelCase												=  "".join(
		    bin(B64_CHARSET.index(lowerCamelCase					)					)[2:].zfill(6					) for char in encoded_data					)

	__lowerCAmelCase												=  [
	    int(binary_stream[index : index + 8]				,		2					)
	    for index in range(0				,		len(lowerCamelCase					)				,		8					)
	]

	return bytes(lowerCamelCase					)


if __name__ == "__main__":
	import doctest

	doctest.testmod()




'''simple docstring'''



from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase	:		Optional[Any]				=   logging.get_logger(__name__)

lowerCAmelCase	:		Optional[int]				=   {
    '''facebook/dpr-ctx_encoder-single-nq-base''': (
        '''https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/resolve/main/config.json'''
    ),
    '''facebook/dpr-question_encoder-single-nq-base''': (
        '''https://huggingface.co/facebook/dpr-question_encoder-single-nq-base/resolve/main/config.json'''
    ),
    '''facebook/dpr-reader-single-nq-base''': (
        '''https://huggingface.co/facebook/dpr-reader-single-nq-base/resolve/main/config.json'''
    ),
    '''facebook/dpr-ctx_encoder-multiset-base''': (
        '''https://huggingface.co/facebook/dpr-ctx_encoder-multiset-base/resolve/main/config.json'''
    ),
    '''facebook/dpr-question_encoder-multiset-base''': (
        '''https://huggingface.co/facebook/dpr-question_encoder-multiset-base/resolve/main/config.json'''
    ),
    '''facebook/dpr-reader-multiset-base''': (
        '''https://huggingface.co/facebook/dpr-reader-multiset-base/resolve/main/config.json'''
    ),
}






class 					UpperCAmelCase__	(		UpperCamelCase__ ):
					a      :     Optional[Any]        =							"""dpr"""



					def __init__(    self			,				UpperCamelCase=3_0522			,				UpperCamelCase=768			,				UpperCamelCase=12			,				UpperCamelCase=12			,				UpperCamelCase=3072			,				UpperCamelCase="gelu"			,				UpperCamelCase=0.1			,				UpperCamelCase=0.1			,				UpperCamelCase=512			,				UpperCamelCase=2			,				UpperCamelCase=0.02			,				UpperCamelCase=1E-12			,				UpperCamelCase=0			,				UpperCamelCase="absolute"			,				UpperCamelCase = 0			,				**UpperCamelCase			,				)     ->			Tuple:
						super().__init__(pad_token_id=UpperCamelCase			,				**UpperCamelCase     )

						__lowerCAmelCase												=  vocab_size
						__lowerCAmelCase												=  hidden_size
						__lowerCAmelCase												=  num_hidden_layers
						__lowerCAmelCase												=  num_attention_heads
						__lowerCAmelCase												=  hidden_act
						__lowerCAmelCase												=  intermediate_size
						__lowerCAmelCase												=  hidden_dropout_prob
						__lowerCAmelCase												=  attention_probs_dropout_prob
						__lowerCAmelCase												=  max_position_embeddings
						__lowerCAmelCase												=  type_vocab_size
						__lowerCAmelCase												=  initializer_range
						__lowerCAmelCase												=  layer_norm_eps
						__lowerCAmelCase												=  projection_dim
						__lowerCAmelCase												=  position_embedding_type