


'''simple docstring'''





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


__lowerCamelCase												=						logging.get_logger(__name__)

__lowerCamelCase												=						{
    '''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 				UpperCAmelCase			(			_snake_case						):
 UpperCAmelCase				=					"realm"


 def __init__(      self							:	List[Any]			,       __lowerCamelCase							:	Any=3_0_5_2_2			,       __lowerCamelCase							:	List[Any]=7_6_8			,       __lowerCamelCase							:	Tuple=1_2_8			,       __lowerCamelCase							:	List[str]=1_2			,       __lowerCamelCase							:	Union[str, Any]=1_2			,       __lowerCamelCase							:	Optional[Any]=8			,       __lowerCamelCase							:	Dict=3_0_7_2			,       __lowerCamelCase							:	Optional[int]="gelu_new"			,       __lowerCamelCase							:	int=0.1			,       __lowerCamelCase							:	Dict=0.1			,       __lowerCamelCase							:	Tuple=5_1_2			,       __lowerCamelCase							:	Any=2			,       __lowerCamelCase							:	Any=0.02			,       __lowerCamelCase							:	Union[str, Any]=1e-12			,       __lowerCamelCase							:	Optional[Any]=2_5_6			,       __lowerCamelCase							:	Any=1_0			,       __lowerCamelCase							:	List[str]=1e-3			,       __lowerCamelCase							:	str=5			,       __lowerCamelCase							:	Union[str, Any]=3_2_0			,       __lowerCamelCase							:	Union[str, Any]=1_3_3_5_3_7_1_8			,       __lowerCamelCase							:	Optional[Any]=5_0_0_0			,       __lowerCamelCase							:	int=1			,       __lowerCamelCase							:	Optional[Any]=0			,       __lowerCamelCase							:	int=2			,       **__lowerCamelCase							:	str			,       ):
    super().__init__(pad_token_id=__lowerCamelCase			,       bos_token_id=__lowerCamelCase			,       eos_token_id=__lowerCamelCase			,       **__lowerCamelCase )

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

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

    # Retrieval config
    UpperCAmelCase__	:Tuple      =      num_block_records
    UpperCAmelCase__	:Any      =      searcher_beam_size







'''simple docstring'''





import pytest

from datasets.splits import SplitDict, SplitInfo
from datasets.utils.py_utils import asdict


@pytest.mark.parametrize(
    '''split_dict''',   [
        SplitDict(),
        SplitDict({'''train''': SplitInfo(name='''train''',   num_bytes=1_337,   num_examples=42,   dataset_name='''my_dataset'''						)}						),
        SplitDict({'''train''': SplitInfo(name='''train''',   num_bytes=1_337,   num_examples=42						)}						),
        SplitDict({'''train''': SplitInfo()}						),
    ],   )
def        a__     (					UpperCamelCase_						:      SplitDict						):
   UpperCAmelCase__	:List[Any]      =      split_dict._to_yaml_list()
   assert len(UpperCamelCase_						) == len(UpperCamelCase_						)
   UpperCAmelCase__	:Tuple      =      SplitDict._from_yaml_list(UpperCamelCase_						)
   for split_name, split_info in split_dict.items():
      # dataset_name field is deprecated, and is therefore not part of the YAML dump
      UpperCAmelCase__	:Union[str, Any]      =      None
      # the split name of split_dict takes over the name of the split info object
      UpperCAmelCase__	:Union[str, Any]      =      split_name
   assert split_dict == reloaded


@pytest.mark.parametrize(
    '''split_info''',   [SplitInfo(), SplitInfo(dataset_name=UpperCamelCase_						), SplitInfo(dataset_name='''my_dataset'''						)]						)
def        a__     (					UpperCamelCase_						:      List[Any]						):
   # For backward compatibility, we need asdict(split_dict) to return split info dictrionaries with the "dataset_name"
   # field even if it's deprecated. This way old versionso of `datasets` can still reload dataset_infos.json files
   UpperCAmelCase__	:List[Any]      =      asdict(SplitDict({'''train''': split_info}						)						)
   assert "dataset_name" in split_dict_asdict["train"]
   assert split_dict_asdict["train"]["dataset_name"] == split_info.dataset_name



