





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


A   : Tuple			=				logging.get_logger(__name__)

A   : List[str]			=				{
    '''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     :	List[str]          =   '''realm'''






			def __init__(      self       :   Optional[Any]							,     __lowerCAmelCase       :   Optional[Any]=3_05_22							,     __lowerCAmelCase       :   List[str]=7_68							,     __lowerCAmelCase       :   Dict=1_28							,     __lowerCAmelCase       :   List[str]=12							,     __lowerCAmelCase       :   int=12							,     __lowerCAmelCase       :   Dict=8							,     __lowerCAmelCase       :   str=30_72							,     __lowerCAmelCase       :   Union[str, Any]="gelu_new"							,     __lowerCAmelCase       :   Optional[Any]=0.1							,     __lowerCAmelCase       :   Tuple=0.1							,     __lowerCAmelCase       :   int=5_12							,     __lowerCAmelCase       :   Union[str, Any]=2							,     __lowerCAmelCase       :   List[str]=0.0_2							,     __lowerCAmelCase       :   List[Any]=1e-12							,     __lowerCAmelCase       :   Union[str, Any]=2_56							,     __lowerCAmelCase       :   Optional[int]=10							,     __lowerCAmelCase       :   Any=1e-3							,     __lowerCAmelCase       :   str=5							,     __lowerCAmelCase       :   int=3_20							,     __lowerCAmelCase       :   int=13_35_37_18							,     __lowerCAmelCase       :   int=50_00							,     __lowerCAmelCase       :   Union[str, Any]=1							,     __lowerCAmelCase       :   Any=0							,     __lowerCAmelCase       :   Union[str, Any]=2							,     **__lowerCAmelCase       :   Any							,     )     ->     Tuple:







					"""simple docstring"""






					super().__init__(pad_token_id=__lowerCAmelCase							,     bos_token_id=__lowerCAmelCase							,     eos_token_id=__lowerCAmelCase							,     **__lowerCAmelCase       )

					# 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










import unittest

import numpy as np







def        __lowerCamelCase (							__a       :np.ndarray   ,					__a       :np.ndarray   ,					__a       :np.ndarray   ,					__a       :np.ndarray | None = None   ,					)		->    np.ndarray:






		"""simple docstring"""

		A__  				=       np.shape(__a   )
		A__  				=       np.shape(__a   )
		A__  				=       np.shape(__a   )

		if shape_a[0] != shape_b[0]:
				A__  				=       (
				    """Expected the same number of rows for A and B. """
				    F'Instead found A of size {shape_a} and B of size {shape_b}'
				)
				raise ValueError(__a   )

		if shape_b[1] != shape_c[1]:
				A__  				=       (
				    """Expected the same number of columns for B and C. """
				    F'Instead found B of size {shape_b} and C of size {shape_c}'
				)
				raise ValueError(__a   )

		A__  				=       pseudo_inv
		if a_inv is None:
				try:
						A__  				=       np.linalg.inv(__a   )
				except np.linalg.LinAlgError:
						raise ValueError(
						    """Input matrix A is not invertible. Cannot compute Schur complement."""   )

		return mat_c - mat_b.T @ a_inv @ mat_b


class   A      (unittest.TestCase   ):
			'''simple docstring'''




			def        a_	(      self       :   Union[str, Any]       )     ->     None:







					"""simple docstring"""






					A__  				=       np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]       )
					A__  				=       np.array([[0, 3], [3, 0], [2, 3]]       )
					A__  				=       np.array([[2, 1], [6, 3]]       )

					A__  				=       schur_complement(__lowerCAmelCase							,     __lowerCAmelCase							,     __lowerCAmelCase       )

					A__  				=       np.block([[a, b], [b.T, c]]       )

					A__  				=       np.linalg.det(__lowerCAmelCase       )
					A__  				=       np.linalg.det(__lowerCAmelCase       )
					A__  				=       np.linalg.det(__lowerCAmelCase       )

					self.assertAlmostEqual(__lowerCAmelCase							,     det_a * det_s       )






			def        a_	(      self       :   str       )     ->     None:







					"""simple docstring"""






					A__  				=       np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]       )
					A__  				=       np.array([[0, 3], [3, 0], [2, 3]]       )
					A__  				=       np.array([[2, 1], [6, 3]]       )

					with self.assertRaises(__lowerCAmelCase       ):
							schur_complement(__lowerCAmelCase							,     __lowerCAmelCase							,     __lowerCAmelCase       )







			def        a_	(      self       :   List[str]       )     ->     None:







					"""simple docstring"""






					A__  				=       np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]       )
					A__  				=       np.array([[0, 3], [3, 0], [2, 3]]       )
					A__  				=       np.array([[2, 1, 3], [6, 3, 5]]       )

					with self.assertRaises(__lowerCAmelCase       ):
							schur_complement(__lowerCAmelCase							,     __lowerCAmelCase							,     __lowerCAmelCase       )


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					unittest.main()



