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


__lowercase											=      logging.get_logger(__name__)

__lowercase											=      {
    '''google/realm-cc-news-pretrained-embedder''': (
        '''https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/config.json'''
    ),
    '''google/realm-cc-news-pretrained-encoder''': (
        '''https://huggingface.co/google/realm-cc-news-pretrained-encoder/resolve/main/config.json'''
    ),
    '''google/realm-cc-news-pretrained-scorer''': (
        '''https://huggingface.co/google/realm-cc-news-pretrained-scorer/resolve/main/config.json'''
    ),
    '''google/realm-cc-news-pretrained-openqa''': (
        '''https://huggingface.co/google/realm-cc-news-pretrained-openqa/aresolve/main/config.json'''
    ),
    '''google/realm-orqa-nq-openqa''': '''https://huggingface.co/google/realm-orqa-nq-openqa/resolve/main/config.json''',
    '''google/realm-orqa-nq-reader''': '''https://huggingface.co/google/realm-orqa-nq-reader/resolve/main/config.json''',
    '''google/realm-orqa-wq-openqa''': '''https://huggingface.co/google/realm-orqa-wq-openqa/resolve/main/config.json''',
    '''google/realm-orqa-wq-reader''': '''https://huggingface.co/google/realm-orqa-wq-reader/resolve/main/config.json''',
    # See all REALM models at https://huggingface.co/models?filter=realm
}


class 			lowerCamelCase_  (     lowercase_				):






    '''simple docstring'''






    a__			:		str      			=   """realm"""







    def __init__(			self				,				__lowercase=30_522				,				__lowercase=768				,				__lowercase=128				,				__lowercase=12				,				__lowercase=12				,				__lowercase=8				,				__lowercase=3_072				,				__lowercase="gelu_new"				,				__lowercase=0.1				,				__lowercase=0.1				,				__lowercase=512				,				__lowercase=2				,				__lowercase=0.02				,				__lowercase=1E-1_2				,				__lowercase=256				,				__lowercase=10				,				__lowercase=1E-3				,				__lowercase=5				,				__lowercase=320				,				__lowercase=13_353_718				,				__lowercase=5_000				,				__lowercase=1				,				__lowercase=0				,				__lowercase=2				,				**__lowercase				,				) ->			str:
        super().__init__(pad_token_id=lowerCamelCase_				,				bos_token_id=lowerCamelCase_				,				eos_token_id=lowerCamelCase_				,				**lowerCamelCase_)

        # Common config
        __UpperCamelCase  :Optional[Any]    						=	vocab_size
        __UpperCamelCase  :int    						=	max_position_embeddings
        __UpperCamelCase  :Union[str, Any]    						=	hidden_size
        __UpperCamelCase  :Optional[int]    						=	retriever_proj_size
        __UpperCamelCase  :Union[str, Any]    						=	num_hidden_layers
        __UpperCamelCase  :str    						=	num_attention_heads
        __UpperCamelCase  :Optional[int]    						=	num_candidates
        __UpperCamelCase  :Dict    						=	intermediate_size
        __UpperCamelCase  :List[Any]    						=	hidden_act
        __UpperCamelCase  :str    						=	hidden_dropout_prob
        __UpperCamelCase  :str    						=	attention_probs_dropout_prob
        __UpperCamelCase  :Dict    						=	initializer_range
        __UpperCamelCase  :Any    						=	type_vocab_size
        __UpperCamelCase  :str    						=	layer_norm_eps

        # Reader config
        __UpperCamelCase  :List[str]    						=	span_hidden_size
        __UpperCamelCase  :List[str]    						=	max_span_width
        __UpperCamelCase  :Union[str, Any]    						=	reader_layer_norm_eps
        __UpperCamelCase  :Union[str, Any]    						=	reader_beam_size
        __UpperCamelCase  :Optional[int]    						=	reader_seq_len

        # Retrieval config
        __UpperCamelCase  :Optional[int]    						=	num_block_records
        __UpperCamelCase  :Union[str, Any]    						=	searcher_beam_size







import os
import unittest

from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer
from transformers.testing_utils import require_jieba, tooslow

from ...test_tokenization_common import TokenizerTesterMixin


@require_jieba
class 			lowerCamelCase_  (     UpperCAmelCase_		,			unittest.TestCase				):






    '''simple docstring'''






    a__			:		Any      			=   CpmAntTokenizer
    a__			:		Optional[Any]      			=   False







    def     UpperCamelCase__     (			self) ->			Any:
        super().setUp()

        __UpperCamelCase  :Optional[int]    						=	[
            '''<d>''',
            '''</d>''',
            '''<s>''',
            '''</s>''',
            '''</_>''',
            '''<unk>''',
            '''<pad>''',
            '''</n>''',
            '''我''',
            '''是''',
            '''C''',
            '''P''',
            '''M''',
            '''A''',
            '''n''',
            '''t''',
        ]
        __UpperCamelCase  :Optional[int]    						=	os.path.join(self.tmpdirname				,				VOCAB_FILES_NAMES['''vocab_file'''])
        with open(self.vocab_file				,				'''w'''				,				encoding='''utf-8''') as vocab_writer:
            vocab_writer.write(''''''.join([x + '''\n''' for x in vocab_tokens]))







    @tooslow
    def     UpperCamelCase__     (			self) ->			Dict:
        __UpperCamelCase  :Tuple    						=	CpmAntTokenizer.from_pretrained('''openbmb/cpm-ant-10b''')
        __UpperCamelCase  :Dict    						=	'''今天天气真好！'''
        __UpperCamelCase  :Tuple    						=	['''今天''', '''天气''', '''真''', '''好''', '''！''']
        __UpperCamelCase  :Optional[Any]    						=	tokenizer.tokenize(__lowercase)
        self.assertListEqual(__lowercase				,				__lowercase)
        __UpperCamelCase  :int    						=	'''今天天气真好！'''
        __UpperCamelCase  :List[str]    						=	[tokenizer.bos_token] + tokens

        __UpperCamelCase  :List[str]    						=	[6, 9_802, 14_962, 2_082, 831, 244]
        self.assertListEqual(tokenizer.convert_tokens_to_ids(__lowercase)				,				__lowercase)

        __UpperCamelCase  :Dict    						=	tokenizer.decode(__lowercase)
        self.assertEqual(__lowercase				,				__lowercase)





