



'''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     SCREAMING_SNAKE_CASE(							A__      ):







	"""simple docstring"""






	lowerCamelCase__      			=	DPRContextEncoderTokenizer
	lowerCamelCase__      			=	DPRContextEncoderTokenizerFast
	lowerCamelCase__      			=	True

@require_tokenizers
class     SCREAMING_SNAKE_CASE(							A__      ):







	"""simple docstring"""






	lowerCamelCase__      			=	DPRQuestionEncoderTokenizer
	lowerCamelCase__      			=	DPRQuestionEncoderTokenizerFast
	lowerCamelCase__      			=	True

@require_tokenizers
class     SCREAMING_SNAKE_CASE(							A__      ):







	"""simple docstring"""






	lowerCamelCase__      			=	DPRReaderTokenizer
	lowerCamelCase__      			=	DPRReaderTokenizerFast
	lowerCamelCase__      			=	True







	@slow
	def 					A     (						self      :					List[Any]		)      ->		Any:
								UpperCAmelCase			:	List[Any]										=		self.tokenizer_class.from_pretrained('''bert-base-uncased'''		)

								UpperCAmelCase			:	Dict										=		tokenizer.encode('''question sequence'''		,      add_special_tokens=__snake_case		)
								UpperCAmelCase			:	str										=		tokenizer.encode('''title sequence'''		,      add_special_tokens=__snake_case		)
								UpperCAmelCase			:	Any										=		tokenizer.encode('''text sequence ''' * 4		,      add_special_tokens=__snake_case		)
								UpperCAmelCase			:	List[Any]										=		[[101] + text_a + [102] + text_a + [102] + text_a]
								UpperCAmelCase			:	str										=		BatchEncoding({'''input_ids''': input_ids}		)

								UpperCAmelCase			:	Any										=		[[0] * len(input_ids[0]		)]
								UpperCAmelCase			:	List[str]										=		[[0] * len(input_ids[0]		)]
								UpperCAmelCase			:	List[str]										=		[0]
								UpperCAmelCase			:	int										=		DPRReaderOutput(__snake_case		,      __snake_case		,      __snake_case		)

								UpperCAmelCase							,		UpperCAmelCase			:	Optional[int]										=		8, 9
								UpperCAmelCase			:	Union[str, Any]										=		10
								UpperCAmelCase			:	Optional[int]										=		10
								UpperCAmelCase			:	Tuple										=		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 					A     (						self      :					Optional[Any]		)      ->		List[Any]:
								UpperCAmelCase			:	Tuple										=		self.tokenizer_class.from_pretrained('''bert-base-uncased'''		)

								UpperCAmelCase			:	Tuple										=		tokenizer.encode('''question sequence'''		,      add_special_tokens=__snake_case		)
								UpperCAmelCase			:	Dict										=		tokenizer.encode('''title sequence'''		,      add_special_tokens=__snake_case		)
								UpperCAmelCase			:	str										=		tokenizer.encode('''text sequence'''		,      add_special_tokens=__snake_case		)
								UpperCAmelCase			:	Tuple										=		[101] + text_a + [102] + text_a + [102] + text_a
								UpperCAmelCase			:	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 typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


UpperCamelCase__:       Tuple							     =      {
    "configuration_splinter": ["SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP", "SplinterConfig"],
    "tokenization_splinter": ["SplinterTokenizer"],
}

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__:       Optional[Any]							     =      ["SplinterTokenizerFast"]

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__:       Any							     =      [
						    "SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST",
						    "SplinterForQuestionAnswering",
						    "SplinterForPreTraining",
						    "SplinterLayer",
						    "SplinterModel",
						    "SplinterPreTrainedModel",
						]


if TYPE_CHECKING:
						from .configuration_splinter import SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP, SplinterConfig
						from .tokenization_splinter import SplinterTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_splinter_fast import SplinterTokenizerFast

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_splinter import (
												    SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST,
												    SplinterForPreTraining,
												    SplinterForQuestionAnswering,
												    SplinterLayer,
												    SplinterModel,
												    SplinterPreTrainedModel,
												)


else:
						import sys

						UpperCamelCase__:       Dict							     =      _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





