


from typing import TYPE_CHECKING

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


_snake_case					=					{
    '''configuration_gpt2''': ['''GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPT2Config''', '''GPT2OnnxConfig'''],
    '''tokenization_gpt2''': ['''GPT2Tokenizer'''],
}

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _snake_case					=					['''GPT2TokenizerFast''']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _snake_case					=					[
       '''GPT2_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''GPT2DoubleHeadsModel''',
       '''GPT2ForQuestionAnswering''',
       '''GPT2ForSequenceClassification''',
       '''GPT2ForTokenClassification''',
       '''GPT2LMHeadModel''',
       '''GPT2Model''',
       '''GPT2PreTrainedModel''',
       '''load_tf_weights_in_gpt2''',
   ]

try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _snake_case					=					[
       '''TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''TFGPT2DoubleHeadsModel''',
       '''TFGPT2ForSequenceClassification''',
       '''TFGPT2LMHeadModel''',
       '''TFGPT2MainLayer''',
       '''TFGPT2Model''',
       '''TFGPT2PreTrainedModel''',
   ]

try:
   if not is_keras_nlp_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _snake_case					=					['''TFGPT2Tokenizer''']

try:
   if not is_flax_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _snake_case					=					['''FlaxGPT2LMHeadModel''', '''FlaxGPT2Model''', '''FlaxGPT2PreTrainedModel''']

if TYPE_CHECKING:
   from .configuration_gpta import GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTaConfig, GPTaOnnxConfig
   from .tokenization_gpta import GPTaTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_gpta_fast import GPTaTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_gpta import (
          GPT2_PRETRAINED_MODEL_ARCHIVE_LIST,
          GPTaDoubleHeadsModel,
          GPTaForQuestionAnswering,
          GPTaForSequenceClassification,
          GPTaForTokenClassification,
          GPTaLMHeadModel,
          GPTaModel,
          GPTaPreTrainedModel,
          load_tf_weights_in_gpta,
      )

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_gpta import (
          TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFGPTaDoubleHeadsModel,
          TFGPTaForSequenceClassification,
          TFGPTaLMHeadModel,
          TFGPTaMainLayer,
          TFGPTaModel,
          TFGPTaPreTrainedModel,
      )

   try:
      if not is_keras_nlp_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_gpta_tf import TFGPTaTokenizer

   try:
      if not is_flax_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_flax_gpta import FlaxGPTaLMHeadModel, FlaxGPTaModel, FlaxGPTaPreTrainedModel

else:
   import sys

   _snake_case					=					_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)







import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_mpnet import MPNetTokenizer


_snake_case					=					logging.get_logger(__name__)

_snake_case					=					{'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

_snake_case					=					{
    '''vocab_file''': {
        '''microsoft/mpnet-base''': '''https://huggingface.co/microsoft/mpnet-base/resolve/main/vocab.txt''',
    },
    '''tokenizer_file''': {
        '''microsoft/mpnet-base''': '''https://huggingface.co/microsoft/mpnet-base/resolve/main/tokenizer.json''',
    },
}

_snake_case					=					{
    '''microsoft/mpnet-base''': 5_12,
}

_snake_case					=					{
    '''microsoft/mpnet-base''': {'''do_lower_case''': True},
}
class      UpperCAmelCase_ ( UpperCamelCase   ):

   '''simple docstring'''




   __A			:				List[str]							=		VOCAB_FILES_NAMES
   __A			:				int							=		PRETRAINED_VOCAB_FILES_MAP
   __A			:				str							=		PRETRAINED_INIT_CONFIGURATION
   __A			:				int							=		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   __A			:				Any							=		MPNetTokenizer
   __A			:				Dict							=		["input_ids", "attention_mask"]






   def __init__(		self						,    __A=None						,    __A=None						,    __A=True						,    __A="<s>"						,    __A="</s>"						,    __A="</s>"						,    __A="<s>"						,    __A="[UNK]"						,    __A="<pad>"						,    __A="<mask>"						,    __A=True						,    __A=None						,    **__A						,    ):






     """simple docstring"""





     super().__init__(
         __A						,    tokenizer_file=__A						,    do_lower_case=__A						,    bos_token=__A						,    eos_token=__A						,    sep_token=__A						,    cls_token=__A						,    unk_token=__A						,    pad_token=__A						,    mask_token=__A						,    tokenize_chinese_chars=__A						,    strip_accents=__A						,    **__A						,    )

     lowerCamelCase			: List[Any]   =    json.loads(self.backend_tokenizer.normalizer.__getstate__()			)
     if (
         pre_tok_state.get("lowercase"						,    __A			) != do_lower_case
         or pre_tok_state.get("strip_accents"						,    __A			) != strip_accents
     ):
       lowerCamelCase			: Dict   =    getattr(__A						,    pre_tok_state.pop("type"			)			)
       lowerCamelCase			: List[str]   =    do_lower_case
       lowerCamelCase			: Tuple   =    strip_accents
       lowerCamelCase			: int   =    pre_tok_class(**__A			)

     lowerCamelCase			: List[Any]   =    do_lower_case






   @property
   def _snake_case   (		self			):






     """simple docstring"""





     if self._mask_token is None:
       if self.verbose:
         logger.error("Using mask_token, but it is not set yet."			)
       return None
     return str(self._mask_token			)






   @mask_token.setter
   def _snake_case   (		self						,    __A			):






     """simple docstring"""





     lowerCamelCase			: Tuple   =    AddedToken(__A						,    lstrip=__A						,    rstrip=__A			) if isinstance(__A						,    __A			) else value
     lowerCamelCase			: Dict   =    value






   def _snake_case   (		self						,    __A						,    __A=None			):






     """simple docstring"""





     lowerCamelCase			: Optional[Any]   =    [self.bos_token_id] + token_ids_a + [self.eos_token_id]
     if token_ids_a is None:
       return output

     return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]






   def _snake_case   (		self						,    __A						,    __A = None			):






     """simple docstring"""





     lowerCamelCase			: Any   =    [self.sep_token_id]
     lowerCamelCase			: Union[str, Any]   =    [self.cls_token_id]

     if token_ids_a is None:
       return len(cls + token_ids_a + sep			) * [0]
     return len(cls + token_ids_a + sep + sep + token_ids_a + sep			) * [0]






   def _snake_case   (		self						,    __A						,    __A = None			):






     """simple docstring"""





     lowerCamelCase			: int   =    self._tokenizer.model.save(__A						,    name=__A			)
     return tuple(__A			)



