




import importlib
import inspect
import os
import re


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_config_docstrings.py
__SCREAMING_SNAKE_CASE 						="""src/transformers"""


# This is to make sure the transformers module imported is the one in the repo.
__SCREAMING_SNAKE_CASE 						=importlib.util.spec_from_file_location(
    """transformers""",
    os.path.join(PATH_TO_TRANSFORMERS, """__init__.py"""),
    submodule_search_locations=[PATH_TO_TRANSFORMERS],
)
__SCREAMING_SNAKE_CASE 						=spec.loader.load_module()

__SCREAMING_SNAKE_CASE 						=transformers.models.auto.configuration_auto.CONFIG_MAPPING

# Regex pattern used to find the checkpoint mentioned in the docstring of `config_class`.
# For example, `[bert-base-uncased](https://huggingface.co/bert-base-uncased)`
__SCREAMING_SNAKE_CASE 						=re.compile("""\[(.+?)\]\((https://huggingface\.co/.+?)\)""")


__SCREAMING_SNAKE_CASE 						={
    """CLIPConfigMixin""",
    """DecisionTransformerConfigMixin""",
    """EncoderDecoderConfigMixin""",
    """RagConfigMixin""",
    """SpeechEncoderDecoderConfigMixin""",
    """VisionEncoderDecoderConfigMixin""",
    """VisionTextDualEncoderConfigMixin""",
}

def 			a   ():
							SCREAMING_SNAKE_CASE_   	=    []

							for config_class in list(CONFIG_MAPPING.values()     ):
														SCREAMING_SNAKE_CASE_   	=    False

														# source code of `config_class`
														SCREAMING_SNAKE_CASE_   	=    inspect.getsource(_lowerCAmelCase     )
														SCREAMING_SNAKE_CASE_   	=    _re_checkpoint.findall(_lowerCAmelCase     )

														for checkpoint in checkpoints:
																					# Each `checkpoint` is a tuple of a checkpoint name and a checkpoint link.
																					# For example, `('bert-base-uncased', 'https://huggingface.co/bert-base-uncased')`
																					SCREAMING_SNAKE_CASE_	,	SCREAMING_SNAKE_CASE_   	=    checkpoint

																					# verify the checkpoint name corresponds to the checkpoint link
																					SCREAMING_SNAKE_CASE_   	=    F"https://huggingface.co/{ckpt_name}"
																					if ckpt_link == ckpt_link_from_name:
																												SCREAMING_SNAKE_CASE_   	=    True
																												break

														SCREAMING_SNAKE_CASE_   	=    config_class.__name__
														if not checkpoint_found and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
																					configs_without_checkpoint.append(_lowerCAmelCase     )

							if len(_lowerCAmelCase     ) > 0:
														SCREAMING_SNAKE_CASE_   	=    '''\n'''.join(sorted(_lowerCAmelCase     )     )
														raise ValueError(F"The following configurations don't contain any valid checkpoint:\n{message}"     )


if __name__ == "__main__":
			check_config_docstrings_have_checkpoints()








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


__SCREAMING_SNAKE_CASE 						=logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE 						={
    """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  __magic_name__						(  __UpperCAmelCase):
				'''simple docstring'''







				SCREAMING_SNAKE_CASE__					:							int	      =					"realm"


				def __init__(							self:   Tuple		,					_lowerCamelCase:   Union[str, Any]=3_05_22		,					_lowerCamelCase:   Tuple=7_68		,					_lowerCamelCase:   str=1_28		,					_lowerCamelCase:   str=12		,					_lowerCamelCase:   int=12		,					_lowerCamelCase:   Union[str, Any]=8		,					_lowerCamelCase:   Optional[Any]=30_72		,					_lowerCamelCase:   str="gelu_new"		,					_lowerCamelCase:   str=0.1		,					_lowerCamelCase:   Union[str, Any]=0.1		,					_lowerCamelCase:   Optional[int]=5_12		,					_lowerCamelCase:   Union[str, Any]=2		,					_lowerCamelCase:   int=0.02		,					_lowerCamelCase:   Tuple=1E-12		,					_lowerCamelCase:   List[Any]=2_56		,					_lowerCamelCase:   Any=10		,					_lowerCamelCase:   Optional[Any]=1E-3		,					_lowerCamelCase:   Any=5		,					_lowerCamelCase:   List[str]=3_20		,					_lowerCamelCase:   List[str]=13_35_37_18		,					_lowerCamelCase:   str=50_00		,					_lowerCamelCase:   str=1		,					_lowerCamelCase:   str=0		,					_lowerCamelCase:   Dict=2		,					**_lowerCamelCase:   Tuple		,					):
											super().__init__(pad_token_id=_lowerCamelCase		,					bos_token_id=_lowerCamelCase		,					eos_token_id=_lowerCamelCase		,					**_lowerCamelCase		)

											# Common config
											SCREAMING_SNAKE_CASE_   	=    vocab_size
											SCREAMING_SNAKE_CASE_   	=    max_position_embeddings
											SCREAMING_SNAKE_CASE_   	=    hidden_size
											SCREAMING_SNAKE_CASE_   	=    retriever_proj_size
											SCREAMING_SNAKE_CASE_   	=    num_hidden_layers
											SCREAMING_SNAKE_CASE_   	=    num_attention_heads
											SCREAMING_SNAKE_CASE_   	=    num_candidates
											SCREAMING_SNAKE_CASE_   	=    intermediate_size
											SCREAMING_SNAKE_CASE_   	=    hidden_act
											SCREAMING_SNAKE_CASE_   	=    hidden_dropout_prob
											SCREAMING_SNAKE_CASE_   	=    attention_probs_dropout_prob
											SCREAMING_SNAKE_CASE_   	=    initializer_range
											SCREAMING_SNAKE_CASE_   	=    type_vocab_size
											SCREAMING_SNAKE_CASE_   	=    layer_norm_eps

											# Reader config
											SCREAMING_SNAKE_CASE_   	=    span_hidden_size
											SCREAMING_SNAKE_CASE_   	=    max_span_width
											SCREAMING_SNAKE_CASE_   	=    reader_layer_norm_eps
											SCREAMING_SNAKE_CASE_   	=    reader_beam_size
											SCREAMING_SNAKE_CASE_   	=    reader_seq_len

											# Retrieval config
											SCREAMING_SNAKE_CASE_   	=    num_block_records
											SCREAMING_SNAKE_CASE_   	=    searcher_beam_size


