"""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__   ):
    snake_case_											=      DPRContextEncoderTokenizer
    snake_case_											=      DPRContextEncoderTokenizerFast
    snake_case_											=      True
@require_tokenizers
class   UpperCAmelCase_	(				lowercase__   ):
    snake_case_											=      DPRQuestionEncoderTokenizer
    snake_case_											=      DPRQuestionEncoderTokenizerFast
    snake_case_											=      True
@require_tokenizers
class   UpperCAmelCase_	(				lowercase__   ):
    snake_case_											=      DPRReaderTokenizer
    snake_case_											=      DPRReaderTokenizerFast
    snake_case_											=      True
    @slow
    def 		_lowerCamelCase      (	self			:       Optional[int]		)						->    Any:
       _lowercase							     =       self.tokenizer_class.from_pretrained("bert-base-uncased"		)

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

       _lowercase							     =       [[0] * len(input_ids[0]		)]
       _lowercase							     =       [[0] * len(input_ids[0]		)]
       _lowercase							     =       [0]
       _lowercase							     =       DPRReaderOutput(_lowercase   ,						_lowercase   ,						_lowercase		)

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




    @slow
    def 		_lowerCamelCase      (	self			:       Union[str, Any]		)						->    str:
       _lowercase							     =       self.tokenizer_class.from_pretrained("bert-base-uncased"		)

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


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__UpperCamelCase       :    Any         =		{
    "configuration_openai": ["OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "OpenAIGPTConfig"],
    "tokenization_openai": ["OpenAIGPTTokenizer"],
}

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCamelCase       :    Optional[int]         =		["OpenAIGPTTokenizerFast"]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCamelCase       :    List[Any]         =		[
      "OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST",
      "OpenAIGPTDoubleHeadsModel",
      "OpenAIGPTForSequenceClassification",
      "OpenAIGPTLMHeadModel",
      "OpenAIGPTModel",
      "OpenAIGPTPreTrainedModel",
      "load_tf_weights_in_openai_gpt",
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCamelCase       :    Tuple         =		[
      "TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST",
      "TFOpenAIGPTDoubleHeadsModel",
      "TFOpenAIGPTForSequenceClassification",
      "TFOpenAIGPTLMHeadModel",
      "TFOpenAIGPTMainLayer",
      "TFOpenAIGPTModel",
      "TFOpenAIGPTPreTrainedModel",
  ]


if TYPE_CHECKING:
  from .configuration_openai import OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP, OpenAIGPTConfig
  from .tokenization_openai import OpenAIGPTTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_openai_fast import OpenAIGPTTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_openai import (
        OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST,
        OpenAIGPTDoubleHeadsModel,
        OpenAIGPTForSequenceClassification,
        OpenAIGPTLMHeadModel,
        OpenAIGPTModel,
        OpenAIGPTPreTrainedModel,
        load_tf_weights_in_openai_gpt,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_openai import (
        TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFOpenAIGPTDoubleHeadsModel,
        TFOpenAIGPTForSequenceClassification,
        TFOpenAIGPTLMHeadModel,
        TFOpenAIGPTMainLayer,
        TFOpenAIGPTModel,
        TFOpenAIGPTPreTrainedModel,
    )

else:
  import sys

  __UpperCamelCase       :    str         =		_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)