"""simple docstring"""



from transformers import (
    DPRContextEncoderTokenizer,
    DPRContextEncoderTokenizerFast,
    DPRQuestionEncoderTokenizer,
    DPRQuestionEncoderTokenizerFast,
    DPRReaderOutput,
    DPRReaderTokenizer,
    DPRReaderTokenizerFast,
)
from transformers.testing_utils import require_tokenizers, slow
from transformers.tokenization_utils_base import BatchEncoding

from ..bert.test_tokenization_bert import BertTokenizationTest
@require_tokenizers
class 	__UpperCAmelCase						(__A    ):







			'''simple docstring'''
			_UpperCamelCase     :	List[str]				    =							DPRContextEncoderTokenizer
			_UpperCamelCase     :	Optional[Any]				    =							DPRContextEncoderTokenizerFast
			_UpperCamelCase     :	str				    =							True





@require_tokenizers
class 	__UpperCAmelCase						(__A    ):







			'''simple docstring'''
			_UpperCamelCase     :	Tuple				    =							DPRQuestionEncoderTokenizer
			_UpperCamelCase     :	Union[str, Any]				    =							DPRQuestionEncoderTokenizerFast
			_UpperCamelCase     :	Union[str, Any]				    =							True





@require_tokenizers
class 	__UpperCAmelCase						(__A    ):







			'''simple docstring'''
			_UpperCamelCase     :	List[str]				    =							DPRReaderTokenizer
			_UpperCamelCase     :	str				    =							DPRReaderTokenizerFast
			_UpperCamelCase     :	Union[str, Any]				    =							True





			@slow
			def 		lowerCamelCase				( self       ):







										'''simple docstring'''


										A__					:    Union[str, Any]														= self.tokenizer_class.from_pretrained("""bert-base-uncased"""       )

										A__					:    Dict														= tokenizer.encode("""question sequence"""      ,			add_special_tokens=snake_case_       )
										A__					:    List[Any]														= tokenizer.encode("""title sequence"""      ,			add_special_tokens=snake_case_       )
										A__					:    Dict														= tokenizer.encode("""text sequence """ * 4      ,			add_special_tokens=snake_case_       )
										A__					:    Optional[Any]														= [[101] + text_a + [102] + text_a + [102] + text_a]
										A__					:    Dict														= BatchEncoding({"""input_ids""": input_ids}       )

										A__					:    Optional[int]														= [[0] * len(input_ids[0]       )]
										A__					:    str														= [[0] * len(input_ids[0]       )]
										A__					:    List[str]														= [0]
										A__					:    Dict														= DPRReaderOutput(snake_case_      ,			snake_case_      ,			snake_case_       )

										A__							,       A__					:    List[Any]														= 8, 9
										A__					:    List[Any]														= 10
										A__					:    str														= 10
										A__					:    Any														= tokenizer.decode_best_spans(snake_case_      ,			snake_case_       )
										self.assertEqual(predicted_spans[0].start_index      ,			snake_case_       )
										self.assertEqual(predicted_spans[0].end_index      ,			snake_case_       )
										self.assertEqual(predicted_spans[0].doc_id      ,			0       )





			@slow
			def 		lowerCamelCase				( self       ):







										'''simple docstring'''


										A__					:    List[str]														= self.tokenizer_class.from_pretrained("""bert-base-uncased"""       )

										A__					:    Tuple														= tokenizer.encode("""question sequence"""      ,			add_special_tokens=snake_case_       )
										A__					:    int														= tokenizer.encode("""title sequence"""      ,			add_special_tokens=snake_case_       )
										A__					:    str														= tokenizer.encode("""text sequence"""      ,			add_special_tokens=snake_case_       )
										A__					:    Optional[int]														= [101] + text_a + [102] + text_a + [102] + text_a
										A__					:    int														= tokenizer(questions=["""question sequence"""]      ,			titles=["""title sequence"""]      ,			texts=["""text sequence"""]       )
										self.assertIn("""input_ids"""      ,			snake_case_       )
										self.assertIn("""attention_mask"""      ,			snake_case_       )
										self.assertListEqual(encoded_input["""input_ids"""][0]      ,			snake_case_       )






"""simple docstring"""



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


_UpperCamelCase         =		logging.get_logger(__name__)

_UpperCamelCase         =		{
    "facebook/opt-125m": "https://huggingface.co/facebook/opt-125m/blob/main/config.json",
    "facebook/opt-350m": "https://huggingface.co/facebook/opt-350m/blob/main/config.json",
    "facebook/opt-1.3b": "https://huggingface.co/facebook/opt-1.3b/blob/main/config.json",
    "facebook/opt-2.7b": "https://huggingface.co/facebook/opt-2.7b/blob/main/config.json",
    "facebook/opt-6.7b": "https://huggingface.co/facebook/opt-6.7b/blob/main/config.json",
    "facebook/opt-13b": "https://huggingface.co/facebook/opt-13b/blob/main/config.json",
}
class 	__UpperCAmelCase						(__A    ):







			'''simple docstring'''
			_UpperCamelCase     :	Dict				    =							'opt'
			_UpperCamelCase     :	Optional[Any]				    =							['past_key_values']





			def __init__( self      ,			snake_case_=50_272      ,			snake_case_=768      ,			snake_case_=12      ,			snake_case_=3_072      ,			snake_case_=2_048      ,			snake_case_=True      ,			snake_case_=False      ,			snake_case_=None      ,			snake_case_=0.1      ,			snake_case_=0.0      ,			snake_case_=12      ,			snake_case_="relu"      ,			snake_case_=0.0      ,			snake_case_=0.02      ,			snake_case_=True      ,			snake_case_=1      ,			snake_case_=2      ,			snake_case_=2      ,			snake_case_=True      ,			snake_case_=True      ,			**snake_case_      ,			):







										'''simple docstring'''


										super().__init__(
										    pad_token_id=snake_case_      ,			bos_token_id=snake_case_      ,			eos_token_id=snake_case_      ,			**snake_case_      ,			)
										A__					:    int														= vocab_size
										A__					:    List[str]														= max_position_embeddings
										A__					:    str														= num_attention_heads
										A__					:    Dict														= word_embed_proj_dim if word_embed_proj_dim is not None else hidden_size
										A__					:    Optional[int]														= ffn_dim
										A__					:    Optional[int]														= hidden_size
										A__					:    int														= num_hidden_layers
										A__					:    str														= dropout
										A__					:    Tuple														= attention_dropout
										A__					:    Optional[Any]														= activation_function
										A__					:    Any														= init_std
										A__					:    Optional[int]														= layerdrop
										A__					:    Optional[int]														= use_cache
										A__					:    int														= do_layer_norm_before
										# We keep these variables at `True` for backward compatibility.
										A__					:    str														= enable_bias
										A__					:    List[str]														= layer_norm_elementwise_affine

										# Note that the only purpose of `_remove_final_layer_norm` is to keep backward compatibility
										# with checkpoints that have been fine-tuned before transformers v4.20.1
										# see https://github.com/facebookresearch/metaseq/pull/164
										A__					:    str														= _remove_final_layer_norm





