
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 						lowercase       (  SCREAMING_SNAKE_CASE__					):
     __a					=    DPRContextEncoderTokenizer
     __a					=    DPRContextEncoderTokenizerFast
     __a					=    True





@require_tokenizers
class 						lowercase       (  SCREAMING_SNAKE_CASE__					):
     __a					=    DPRQuestionEncoderTokenizer
     __a					=    DPRQuestionEncoderTokenizerFast
     __a					=    True





@require_tokenizers
class 						lowercase       (  SCREAMING_SNAKE_CASE__					):
     __a					=    DPRReaderTokenizer
     __a					=    DPRReaderTokenizerFast
     __a					=    True
     @slow
     def lowercase_			(		self    ):
        """simple docstring"""







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

        lowerCAmelCase__ :    Optional[Any]				      =			tokenizer.encode('''question sequence''' ,	add_special_tokens=SCREAMING_SNAKE_CASE__    )
        lowerCAmelCase__ :    str				      =			tokenizer.encode('''title sequence''' ,	add_special_tokens=SCREAMING_SNAKE_CASE__    )
        lowerCAmelCase__ :    int				      =			tokenizer.encode('''text sequence ''' * 4 ,	add_special_tokens=SCREAMING_SNAKE_CASE__    )
        lowerCAmelCase__ :    List[Any]				      =			[[101] + text_a + [102] + text_a + [102] + text_a]
        lowerCAmelCase__ :    Tuple				      =			BatchEncoding({'''input_ids''': input_ids}    )

        lowerCAmelCase__ :    List[str]				      =			[[0] * len(input_ids[0]    )]
        lowerCAmelCase__ :    str				      =			[[0] * len(input_ids[0]    )]
        lowerCAmelCase__ :    List[Any]				      =			[0]
        lowerCAmelCase__ :    List[Any]				      =			DPRReaderOutput(SCREAMING_SNAKE_CASE__ ,	SCREAMING_SNAKE_CASE__ ,	SCREAMING_SNAKE_CASE__    )

        lowerCAmelCase__      ,				lowerCAmelCase__ :    List[Any]				      =			8, 9
        lowerCAmelCase__ :    Optional[Any]				      =			10
        lowerCAmelCase__ :    Tuple				      =			10
        lowerCAmelCase__ :    Any				      =			tokenizer.decode_best_spans(SCREAMING_SNAKE_CASE__ ,	SCREAMING_SNAKE_CASE__    )
        self.assertEqual(predicted_spans[0].start_index ,	SCREAMING_SNAKE_CASE__    )
        self.assertEqual(predicted_spans[0].end_index ,	SCREAMING_SNAKE_CASE__    )
        self.assertEqual(predicted_spans[0].doc_id ,	0    )
     @slow
     def lowercase_			(		self    ):
        """simple docstring"""







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

        lowerCAmelCase__ :    Dict				      =			tokenizer.encode('''question sequence''' ,	add_special_tokens=SCREAMING_SNAKE_CASE__    )
        lowerCAmelCase__ :    Union[str, Any]				      =			tokenizer.encode('''title sequence''' ,	add_special_tokens=SCREAMING_SNAKE_CASE__    )
        lowerCAmelCase__ :    Any				      =			tokenizer.encode('''text sequence''' ,	add_special_tokens=SCREAMING_SNAKE_CASE__    )
        lowerCAmelCase__ :    Any				      =			[101] + text_a + [102] + text_a + [102] + text_a
        lowerCAmelCase__ :    List[Any]				      =			tokenizer(questions=['''question sequence'''] ,	titles=['''title sequence'''] ,	texts=['''text sequence''']    )
        self.assertIn('''input_ids''' ,	SCREAMING_SNAKE_CASE__    )
        self.assertIn('''attention_mask''' ,	SCREAMING_SNAKE_CASE__    )
        self.assertListEqual(encoded_input['''input_ids'''][0] ,	SCREAMING_SNAKE_CASE__    )





# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import sys
import warnings
from os.path import abspath, dirname, join


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
A__       :   Optional[Any]   						=					abspath(join(dirname(dirname(dirname(__file__))), """src"""))
sys.path.insert(1, git_repo_path)


# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action="""ignore""", category=FutureWarning)



def      _a     (   __UpperCamelCase       :  Tuple    ):
			from transformers.testing_utils import pytest_addoption_shared

			pytest_addoption_shared(__UpperCamelCase    )



def      _a     (   __UpperCamelCase       :  int    ):
			from transformers.testing_utils import pytest_terminal_summary_main

			lowerCAmelCase__ :    int				      =			terminalreporter.config.getoption('''--make-reports'''    )
			if make_reports:
						pytest_terminal_summary_main(__UpperCamelCase	,id=__UpperCamelCase    )



