

"""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					(  __lowercase		):
		SCREAMING_SNAKE_CASE														=       DPRContextEncoderTokenizer
		SCREAMING_SNAKE_CASE														=       DPRContextEncoderTokenizerFast
		SCREAMING_SNAKE_CASE														=       True





@require_tokenizers
class      __UpperCamelCase					(  __lowercase		):
		SCREAMING_SNAKE_CASE														=       DPRQuestionEncoderTokenizer
		SCREAMING_SNAKE_CASE														=       DPRQuestionEncoderTokenizerFast
		SCREAMING_SNAKE_CASE														=       True





@require_tokenizers
class      __UpperCamelCase					(  __lowercase		):
		SCREAMING_SNAKE_CASE														=       DPRReaderTokenizer
		SCREAMING_SNAKE_CASE														=       DPRReaderTokenizerFast
		SCREAMING_SNAKE_CASE														=       True


		@slow
		def    SCREAMING_SNAKE_CASE__  (self					:						Any):
							A     =   self.tokenizer_class.from_pretrained("bert-base-uncased")

							A     =   tokenizer.encode("question sequence"	,	add_special_tokens=_UpperCamelCase)
							A     =   tokenizer.encode("title sequence"	,	add_special_tokens=_UpperCamelCase)
							A     =   tokenizer.encode("text sequence " * 4	,	add_special_tokens=_UpperCamelCase)
							A     =   [[1_0_1] + text_a + [1_0_2] + text_a + [1_0_2] + text_a]
							A     =   BatchEncoding({"input_ids": input_ids})

							A     =   [[0] * len(input_ids[0])]
							A     =   [[0] * len(input_ids[0])]
							A     =   [0]
							A     =   DPRReaderOutput(_UpperCamelCase	,	_UpperCamelCase	,	_UpperCamelCase)

							A     ,       A     =   8, 9
							A     =   1_0
							A     =   1_0
							A     =   tokenizer.decode_best_spans(_UpperCamelCase	,	_UpperCamelCase)
							self.assertEqual(predicted_spans[0].start_index	,	_UpperCamelCase)
							self.assertEqual(predicted_spans[0].end_index	,	_UpperCamelCase)
							self.assertEqual(predicted_spans[0].doc_id	,	0)


		@slow
		def    SCREAMING_SNAKE_CASE__  (self					:						Optional[int]):
							A     =   self.tokenizer_class.from_pretrained("bert-base-uncased")

							A     =   tokenizer.encode("question sequence"	,	add_special_tokens=_UpperCamelCase)
							A     =   tokenizer.encode("title sequence"	,	add_special_tokens=_UpperCamelCase)
							A     =   tokenizer.encode("text sequence"	,	add_special_tokens=_UpperCamelCase)
							A     =   [1_0_1] + text_a + [1_0_2] + text_a + [1_0_2] + text_a
							A     =   tokenizer(questions=["question sequence"]	,	titles=["title sequence"]	,	texts=["text sequence"])
							self.assertIn("input_ids"	,	_UpperCamelCase)
							self.assertIn("attention_mask"	,	_UpperCamelCase)
							self.assertListEqual(encoded_input["input_ids"][0]	,	_UpperCamelCase)













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      __SCREAMING_SNAKE_CASE       ( __lowercase):
						_SCREAMING_SNAKE_CASE						:							Tuple				=       DPRContextEncoderTokenizer
						_SCREAMING_SNAKE_CASE						:							Any				=       DPRContextEncoderTokenizerFast
						_SCREAMING_SNAKE_CASE						:							str				=       True




@require_tokenizers
class      __SCREAMING_SNAKE_CASE       ( __lowercase):
						_SCREAMING_SNAKE_CASE						:							Optional[Any]				=       DPRQuestionEncoderTokenizer
						_SCREAMING_SNAKE_CASE						:							List[Any]				=       DPRQuestionEncoderTokenizerFast
						_SCREAMING_SNAKE_CASE						:							Optional[Any]				=       True




@require_tokenizers
class      __SCREAMING_SNAKE_CASE       ( __lowercase):
						_SCREAMING_SNAKE_CASE						:							Any				=       DPRReaderTokenizer
						_SCREAMING_SNAKE_CASE						:							int				=       DPRReaderTokenizerFast
						_SCREAMING_SNAKE_CASE						:							List[str]				=       True






						@slow
						def    UpperCamelCase__   (						self ):






												"""simple docstring"""
												lowerCAmelCase__         =    self.tokenizer_class.from_pretrained('bert-base-uncased' )

												lowerCAmelCase__         =    tokenizer.encode('question sequence'  ,    add_special_tokens=_UpperCamelCase )
												lowerCAmelCase__         =    tokenizer.encode('title sequence'  ,    add_special_tokens=_UpperCamelCase )
												lowerCAmelCase__         =    tokenizer.encode('text sequence ' * 4  ,    add_special_tokens=_UpperCamelCase )
												lowerCAmelCase__         =    [[1_01] + text_a + [1_02] + text_a + [1_02] + text_a]
												lowerCAmelCase__         =    BatchEncoding({'input_ids': input_ids} )

												lowerCAmelCase__         =    [[0] * len(input_ids[0] )]
												lowerCAmelCase__         =    [[0] * len(input_ids[0] )]
												lowerCAmelCase__         =    [0]
												lowerCAmelCase__         =    DPRReaderOutput(_UpperCamelCase  ,    _UpperCamelCase  ,    _UpperCamelCase )

												lowerCAmelCase__    ,							lowerCAmelCase__         =    8, 9
												lowerCAmelCase__         =    10
												lowerCAmelCase__         =    10
												lowerCAmelCase__         =    tokenizer.decode_best_spans(_UpperCamelCase  ,    _UpperCamelCase )
												self.assertEqual(predicted_spans[0].start_index  ,    _UpperCamelCase )
												self.assertEqual(predicted_spans[0].end_index  ,    _UpperCamelCase )
												self.assertEqual(predicted_spans[0].doc_id  ,    0 )







						@slow
						def    UpperCamelCase__   (						self ):






												"""simple docstring"""
												lowerCAmelCase__         =    self.tokenizer_class.from_pretrained('bert-base-uncased' )

												lowerCAmelCase__         =    tokenizer.encode('question sequence'  ,    add_special_tokens=_UpperCamelCase )
												lowerCAmelCase__         =    tokenizer.encode('title sequence'  ,    add_special_tokens=_UpperCamelCase )
												lowerCAmelCase__         =    tokenizer.encode('text sequence'  ,    add_special_tokens=_UpperCamelCase )
												lowerCAmelCase__         =    [1_01] + text_a + [1_02] + text_a + [1_02] + text_a
												lowerCAmelCase__         =    tokenizer(questions=['question sequence']  ,    titles=['title sequence']  ,    texts=['text sequence'] )
												self.assertIn('input_ids'  ,    _UpperCamelCase )
												self.assertIn('attention_mask'  ,    _UpperCamelCase )
												self.assertListEqual(encoded_input['input_ids'][0]  ,    _UpperCamelCase )





