




"""simple docstring"""






import json
import os
from typing import Optional, Tuple

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


lowercase__			=		logging.get_logger(__name__)

lowercase__			=		{"""vocab_file""": """vocab.json"""}

lowercase__			=		{
    """vocab_file""": {
        """mgp-str""": """https://huggingface.co/alibaba-damo/mgp-str-base/blob/main/vocab.json""",
    }
}

lowercase__			=		{"""mgp-str""": 27}






class lowerCAmelCase__      (	lowercase		):






			'''simple docstring'''



			lowerCamelCase__ =     VOCAB_FILES_NAMES
			lowerCamelCase__ =     PRETRAINED_VOCAB_FILES_MAP
			lowerCamelCase__ =     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			def __init__(    self    , lowercase    , lowercase="[GO]"    , lowercase="[GO]"    , lowercase="[s]"    , lowercase="[GO]"    , **lowercase    ):
							super().__init__(
							    unk_token=lowercase    , bos_token=lowercase    , eos_token=lowercase    , pad_token=lowercase    , **lowercase    , )

							with open(lowercase    , encoding='utf-8'    ) as vocab_handle:
											_lowerCamelCase	:     Dict       =       json.load(lowercase    )
							_lowerCamelCase	:     Optional[Any]       =       {v: k for k, v in self.vocab.items()}
			@property
			def    A_       (    self    ):
							return len(self.vocab    )
			def    A_       (    self    ):
							return dict(self.vocab    , **self.added_tokens_encoder    )
			def    A_       (    self    , lowercase    ):
							_lowerCamelCase	:     str       =       []
							for s in text:
											char_tokens.extend(lowercase    )
							return char_tokens
			def    A_       (    self    , lowercase    ):
							return self.vocab.get(lowercase    , self.vocab.get(self.unk_token    )    )
			def    A_       (    self    , lowercase    ):
							return self.decoder.get(lowercase    )






			def    A_       (    self    , lowercase    , lowercase = None    ):
							if not os.path.isdir(lowercase    ):
											logger.error('Vocabulary path ({}) should be a directory'.format(lowercase    )    )
											return
							_lowerCamelCase	:     List[str]       =       os.path.join(
							    lowercase    , (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file']    )

							with open(lowercase    , 'w'    , encoding='utf-8'    ) as f:
											f.write(json.dumps(self.vocab    , indent=2    , sort_keys=lowercase    , ensure_ascii=lowercase    ) + '\n'    )

							return (vocab_file,)





"""simple docstring"""






from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowercase__			=		logging.get_logger(__name__)

lowercase__			=		{
    """facebook/dpr-ctx_encoder-single-nq-base""": (
        """https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/resolve/main/config.json"""
    ),
    """facebook/dpr-question_encoder-single-nq-base""": (
        """https://huggingface.co/facebook/dpr-question_encoder-single-nq-base/resolve/main/config.json"""
    ),
    """facebook/dpr-reader-single-nq-base""": (
        """https://huggingface.co/facebook/dpr-reader-single-nq-base/resolve/main/config.json"""
    ),
    """facebook/dpr-ctx_encoder-multiset-base""": (
        """https://huggingface.co/facebook/dpr-ctx_encoder-multiset-base/resolve/main/config.json"""
    ),
    """facebook/dpr-question_encoder-multiset-base""": (
        """https://huggingface.co/facebook/dpr-question_encoder-multiset-base/resolve/main/config.json"""
    ),
    """facebook/dpr-reader-multiset-base""": (
        """https://huggingface.co/facebook/dpr-reader-multiset-base/resolve/main/config.json"""
    ),
}






class lowerCAmelCase__      (	lowercase		):






			'''simple docstring'''



			lowerCamelCase__ =     """dpr"""
			def __init__(    self    , lowercase=30522    , lowercase=768    , lowercase=12    , lowercase=12    , lowercase=3072    , lowercase="gelu"    , lowercase=0.1    , lowercase=0.1    , lowercase=512    , lowercase=2    , lowercase=0.02    , lowercase=1E-12    , lowercase=0    , lowercase="absolute"    , lowercase = 0    , **lowercase    , ):
							super().__init__(pad_token_id=lowercase    , **lowercase    )

							_lowerCamelCase	:     int       =       vocab_size
							_lowerCamelCase	:     Optional[int]       =       hidden_size
							_lowerCamelCase	:     str       =       num_hidden_layers
							_lowerCamelCase	:     Optional[int]       =       num_attention_heads
							_lowerCamelCase	:     Tuple       =       hidden_act
							_lowerCamelCase	:     int       =       intermediate_size
							_lowerCamelCase	:     str       =       hidden_dropout_prob
							_lowerCamelCase	:     Tuple       =       attention_probs_dropout_prob
							_lowerCamelCase	:     Union[str, Any]       =       max_position_embeddings
							_lowerCamelCase	:     str       =       type_vocab_size
							_lowerCamelCase	:     int       =       initializer_range
							_lowerCamelCase	:     Optional[int]       =       layer_norm_eps
							_lowerCamelCase	:     Dict       =       projection_dim
							_lowerCamelCase	:     int       =       position_embedding_type