


"""simple docstring"""







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


lowerCamelCase_   :   str									=  logging.get_logger(__name__)

lowerCamelCase_   :   Dict									=  {
    """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				(       _SCREAMING_SNAKE_CASE			):






 """simple docstring"""




 __lowerCAmelCase 					=  "realm"


 def __init__(		self ,    __A=3_0522 ,    __A=768 ,    __A=128 ,    __A=12 ,    __A=12 ,    __A=8 ,    __A=3072 ,    __A="gelu_new" ,    __A=0.1 ,    __A=0.1 ,    __A=512 ,    __A=2 ,    __A=0.02 ,    __A=1E-1_2 ,    __A=256 ,    __A=10 ,    __A=1E-3 ,    __A=5 ,    __A=320 ,    __A=1335_3718 ,    __A=5000 ,    __A=1 ,    __A=0 ,    __A=2 ,    **__A ,    )					->     str:
     super().__init__(pad_token_id=__A ,    bos_token_id=__A ,    eos_token_id=__A ,    **__A						)

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

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

     # Retrieval config
     a 		=num_block_records
     a 		=searcher_beam_size






"""simple docstring"""




from typing import Optional, Union

import torch
from torch import nn

from ...configuration_utils import ConfigMixin, register_to_config
from ...models.modeling_utils import ModelMixin

class  _UpperCAmelCase  (   UpperCAmelCase__			,   UpperCAmelCase__		):



      '''simple docstring'''

      @register_to_config
      def __init__(     self					,      snake_case_ = 7_6_8					,      ):

        """simple docstring"""

        super().__init__()

        A_  :       Optional[int]										=  nn.Parameter(torch.zeros(1					,      snake_case_  )  )
        A_  :       Optional[int]										=  nn.Parameter(torch.ones(1					,      snake_case_  )  )

      def 					lowerCamelCase_			(     self					,      snake_case_ = None					,      snake_case_ = None					,      ):

        """simple docstring"""

        A_  :       str										=  nn.Parameter(self.mean.to(snake_case_  ).to(snake_case_  )  )
        A_  :       Optional[int]										=  nn.Parameter(self.std.to(snake_case_  ).to(snake_case_  )  )
        return self

      def 					lowerCamelCase_			(     self					,      snake_case_  ):

        """simple docstring"""

        A_  :       Tuple										=  (embeds - self.mean) * 1.0 / self.std
        return embeds

      def 					lowerCamelCase_			(     self					,      snake_case_  ):

        """simple docstring"""

        A_  :       List[str]										=  (embeds * self.std) + self.mean
        return embeds