



'''simple docstring'''



import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin






class 					UpperCAmelCase__	(		__a ):
					a      :     str        =							"""MCTCTFeatureExtractor"""
					a      :     Any        =							"""AutoTokenizer"""



					def __init__(    self			,				UpperCamelCase			,				UpperCamelCase     )     ->			Union[str, Any]:
						super().__init__(A__			,				A__     )
						__lowerCAmelCase												=  self.feature_extractor
						__lowerCAmelCase												=  False



					def __call__(    self			,				*UpperCamelCase			,				**UpperCamelCase     )     ->			Tuple:
						# For backward compatibility
						if self._in_target_context_manager:
							return self.current_processor(*A__			,				**A__     )

						if "raw_speech" in kwargs:
							warnings.warn("Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead."     )
							__lowerCAmelCase												=  kwargs.pop("raw_speech"     )
						else:
							__lowerCAmelCase												=  kwargs.pop("audio"			,				A__     )
						__lowerCAmelCase												=  kwargs.pop("sampling_rate"			,				A__     )
						__lowerCAmelCase												=  kwargs.pop("text"			,				A__     )
						if len(A__     ) > 0:
							__lowerCAmelCase												=  args[0]
							__lowerCAmelCase												=  args[1:]

						if audio is None and text is None:
							raise ValueError("You need to specify either an `audio` or `text` input to process."     )

						if audio is not None:
							__lowerCAmelCase												=  self.feature_extractor(A__			,				*A__			,				sampling_rate=A__			,				**A__     )
						if text is not None:
							__lowerCAmelCase												=  self.tokenizer(A__			,				**A__     )

						if text is None:
							return inputs
						elif audio is None:
							return encodings
						else:
							__lowerCAmelCase												=  encodings["input_ids"]
							return inputs



					def        UpperCAmelCase_ (    self			,				*UpperCamelCase			,				**UpperCamelCase     )     ->			List[str]:
						return self.tokenizer.batch_decode(*A__			,				**A__     )



					def        UpperCAmelCase_ (    self			,				*UpperCamelCase			,				**UpperCamelCase     )     ->			Dict:
						# For backward compatibility
						if self._in_target_context_manager:
							return self.current_processor.pad(*A__			,				**A__     )

						__lowerCAmelCase												=  kwargs.pop("input_features"			,				A__     )
						__lowerCAmelCase												=  kwargs.pop("labels"			,				A__     )
						if len(A__     ) > 0:
							__lowerCAmelCase												=  args[0]
							__lowerCAmelCase												=  args[1:]

						if input_features is not None:
							__lowerCAmelCase												=  self.feature_extractor.pad(A__			,				*A__			,				**A__     )
						if labels is not None:
							__lowerCAmelCase												=  self.tokenizer.pad(A__			,				**A__     )

						if labels is None:
							return input_features
						elif input_features is None:
							return labels
						else:
							__lowerCAmelCase												=  labels["input_ids"]
							return input_features



					def        UpperCAmelCase_ (    self			,				*UpperCamelCase			,				**UpperCamelCase     )     ->			Dict:
						return self.tokenizer.decode(*A__			,				**A__     )



					@contextmanager
					def        UpperCAmelCase_ (    self     )     ->			Any:
						warnings.warn(
						    "`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your "
						    "labels by using the argument `text` of the regular `__call__` method (either in the same call as "
						    "your audio inputs, or in a separate call."     )
						__lowerCAmelCase												=  True
						__lowerCAmelCase												=  self.tokenizer
						yield
						__lowerCAmelCase												=  self.feature_extractor
						__lowerCAmelCase												=  False




'''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