


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


_snake_case	:						Optional[Any]         =							{
    "configuration_tapas": ["TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP", "TapasConfig"],
    "tokenization_tapas": ["TapasTokenizer"],
}

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_snake_case	:						Tuple         =							[
			    "TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST",
			    "TapasForMaskedLM",
			    "TapasForQuestionAnswering",
			    "TapasForSequenceClassification",
			    "TapasModel",
			    "TapasPreTrainedModel",
			    "load_tf_weights_in_tapas",
			]
try:
			if not is_tf_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_snake_case	:						Optional[int]         =							[
			    "TF_TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST",
			    "TFTapasForMaskedLM",
			    "TFTapasForQuestionAnswering",
			    "TFTapasForSequenceClassification",
			    "TFTapasModel",
			    "TFTapasPreTrainedModel",
			]


if TYPE_CHECKING:
			from .configuration_tapas import TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP, TapasConfig
			from .tokenization_tapas import TapasTokenizer

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_tapas import (
						    TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST,
						    TapasForMaskedLM,
						    TapasForQuestionAnswering,
						    TapasForSequenceClassification,
						    TapasModel,
						    TapasPreTrainedModel,
						    load_tf_weights_in_tapas,
						)

			try:
						if not is_tf_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_tf_tapas import (
						    TF_TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST,
						    TFTapasForMaskedLM,
						    TFTapasForQuestionAnswering,
						    TFTapasForSequenceClassification,
						    TFTapasModel,
						    TFTapasPreTrainedModel,
						)


else:
			import sys

			_snake_case	:						Tuple         =							_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)


"""simple docstring"""


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


UpperCAmelCase__			=    logging.get_logger(__name__)

UpperCAmelCase__			=    {
    """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 							a					(		lowerCAmelCase_ ):
    _snake_case  :	List[Any]  				=				'realm'


    def __init__(       self						:	List[Any] ,					__lowerCAmelCase						:	List[str]=3_0522 ,					__lowerCAmelCase						:	Tuple=768 ,					__lowerCAmelCase						:	List[Any]=128 ,					__lowerCAmelCase						:	Tuple=12 ,					__lowerCAmelCase						:	List[str]=12 ,					__lowerCAmelCase						:	Union[str, Any]=8 ,					__lowerCAmelCase						:	List[str]=3072 ,					__lowerCAmelCase						:	Union[str, Any]="gelu_new" ,					__lowerCAmelCase						:	str=0.1 ,					__lowerCAmelCase						:	Tuple=0.1 ,					__lowerCAmelCase						:	List[str]=512 ,					__lowerCAmelCase						:	Dict=2 ,					__lowerCAmelCase						:	List[Any]=0.02 ,					__lowerCAmelCase						:	Optional[int]=1e-1_2 ,					__lowerCAmelCase						:	Any=256 ,					__lowerCAmelCase						:	Union[str, Any]=10 ,					__lowerCAmelCase						:	Dict=1e-3 ,					__lowerCAmelCase						:	str=5 ,					__lowerCAmelCase						:	str=320 ,					__lowerCAmelCase						:	Tuple=1335_3718 ,					__lowerCAmelCase						:	Optional[Any]=5000 ,					__lowerCAmelCase						:	int=1 ,					__lowerCAmelCase						:	Dict=0 ,					__lowerCAmelCase						:	Any=2 ,					**__lowerCAmelCase						:	Optional[int] ,					):
      super().__init__(pad_token_id=__lowerCAmelCase ,					bos_token_id=__lowerCAmelCase ,					eos_token_id=__lowerCAmelCase ,					**__lowerCAmelCase       )

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

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

      # Retrieval config
      _UpperCAmelCase    			=   num_block_records
      _UpperCAmelCase    			=   searcher_beam_size
